-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support synchronization points at fixed offsets, without pattern search.
If a synchronization point (i.e., a field with `&synchronize`) can be determined to reside at a fixed offset from either the start of a unit or a previous synchronization point, we can now leverage that after an error to jump there directly to resume parsing.
- Loading branch information
Showing
10 changed files
with
134 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/Baseline/spicy.types.unit.synchronize-fixed-size/output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. | ||
[$xa=[$x1=b"123", $x2=b"45"], $xb=[$x1=b"123", $x2=b"45"], $y=[$y1=b"ab", $y2=25444, $y3=101], $z=b"DONE"] | ||
=== | ||
* synchronized | ||
* confirmed | ||
[$xa=[$x1=b"12.", $x2=(not set)], $xb=(not set), $y=[$y1=b"ab", $y2=25444, $y3=101], $z=b"DONE"] | ||
=== | ||
* synchronized | ||
[$xa=[$x1=b"12.", $x2=(not set)], $xb=(not set), $y=[$y1=b"ab", $y2=25444, $y3=101], $z=b"DONE"] | ||
[error] terminating with uncaught exception of type spicy::rt::ParseError: successful synchronization never confirmed: &requires failed: ($$ == b"123") (<...>/synchronize-fixed-size.spicy:19:23-19:46) | ||
=== | ||
* synchronized | ||
* confirmed | ||
[$xa=[$x1=b"123", $x2=b"45"], $xb=[$x1=b"12.", $x2=(not set)], $y=[$y1=b"ab", $y2=25444, $y3=101], $z=b"DONE"] | ||
=== | ||
=== | ||
[error] terminating with uncaught exception of type spicy::rt::ParseError: expected bytes literal "DONE" but input starts with "DO.E" (<...>/synchronize-fixed-size.spicy:33:8-33:14) | ||
=== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# @TEST-EXEC: printf 1234512345abcdeDONEc | spicy-driver -d %INPUT >>output 2>&1 | ||
# @TEST-EXEC: echo === >>output | ||
# @TEST-EXEC: printf 12.4512345abcdeDONEc | spicy-driver -d %INPUT >>output 2>&1 | ||
# @TEST-EXEC: echo === >>output | ||
# @TEST-EXEC-FAIL: printf 12.4512345abcdeDONE- | spicy-driver -d %INPUT >>output 2>&1 | ||
# @TEST-EXEC: echo === >>output | ||
# @TEST-EXEC: printf 1234512.45abcdeDONEc | spicy-driver -d %INPUT >>output 2>&1 | ||
# @TEST-EXEC: echo === >>output | ||
# TEST-EXEC: printf 1234512345ab.deDONEc | spicy-driver -d %INPUT >>output 2>&1 | ||
# @TEST-EXEC: echo === >>output | ||
# @TEST-EXEC-FAIL: printf 1234512345abcdeDO.E- | spicy-driver -d %INPUT >>output 2>&1 | ||
# @TEST-EXEC: echo === >>output | ||
# @TEST-EXEC: btest-diff output | ||
# | ||
# @TEST-DOC: Check that we can synchronize after errors in fixed-size fields. | ||
module Test; | ||
|
||
type X = unit { | ||
x1: bytes &size=3 &requires=($$ == b"123"); | ||
x2: bytes &eod; | ||
}; | ||
|
||
type Y = unit { | ||
y1: b"ab"; | ||
y2: uint16; | ||
y3: uint8; | ||
}; | ||
|
||
public type Foo = unit { | ||
xa: X &size=5; | ||
xb: X &size=5; | ||
y: Y &synchronize; | ||
z: b"DONE"; | ||
|
||
: bytes &size=1 { if ( $$ == b"c" ) confirm; } | ||
|
||
on %synced { | ||
print "* synchronized"; | ||
} | ||
|
||
on %confirmed { | ||
print "* confirmed"; | ||
} | ||
|
||
on %done { | ||
print self; | ||
} | ||
}; |