Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add lazy isolation mode #111

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: More detailed isolationUnderParse error
  • Loading branch information
414owen committed Jul 24, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c97df679ecc5c4724b56187b4752fabd6c1a78fe
8 changes: 6 additions & 2 deletions src/Data/Serialize/Get.hs
Original file line number Diff line number Diff line change
@@ -421,7 +421,7 @@ negativeIsolation :: Get a
negativeIsolation = fail "Attempted to isolate a negative number of bytes"

isolationUnderParse :: Get a
isolationUnderParse = fail "Isolated parser didn't consume all input"
isolationUnderParse = fail "Isolated parser didn't consume all input"

isolationUnderSupply :: Get a
isolationUnderSupply = fail "Too few bytes supplied to isolated parser"
@@ -467,7 +467,11 @@ isolateLazy n parser = do
failRaw msg stack
Done a bs -> do
bytesRead' <- bytesRead
unless (bytesRead' - initialBytesRead == n && B.null bs) isolationUnderParse
unless (bytesRead' - initialBytesRead == n && B.null bs)
$ fail $ "Isolated parser didn't consume all input. "
<> "Internal leftovers: " <> show bs
<> ", bytesRead: " <> show (bytesRead' - initialBytesRead)
<> ", isolation amt: " <> show n
pure a
Partial cont -> do
pos <- bytesRead