-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add parser backtracking #25
Labels
Port V1
Functionality that still needs to ported from the the old Spicy research prototype
Comments
bbannier
added
Port V1
Functionality that still needs to ported from the the old Spicy research prototype
Spicy
labels
Apr 6, 2020
closed |
reopened |
marked this issue as related to #118 |
rsmmr
added a commit
that referenced
this issue
Dec 2, 2020
If a field is marked with ``&try``, a later call to ``self.backtrack()`` anywhere down in the parse tree will return to that position and continue there. (This is ported over the old prototype). Example: export type test = unit { a: bytes &length=4; foo: Foo &try; bar: Bar; b: bytes &length=6; on %done { print self; } }; type Foo = unit { a: int8 { print "Foo.a", self; } b: int8 { print "Backtracking"; self.backtrack(); } c: int8 { print "Foo.c", self; } }; type Bar = unit { a: int8 { print "Bar.a", self; } b: int8 { print "Bar.b", self; } c: int8 { print "Bar.c", self; } }; # printf '1234\001\002\003567890' | pac-driver backtrack.pac2 Foo.a <a=1, b=(not set), c=(not set)> Backtracking Bar.a <a=1, b=(not set), c=(not set)> Bar.b <a=1, b=2, c=(not set)> Bar.c <a=1, b=2, c=3> <a=1234, foo=(Null), bar=<a=1, b=2, c=3>, b=567890> Closes #25.
rsmmr
added a commit
that referenced
this issue
Dec 8, 2020
If a field is marked with ``&try``, a later call to ``self.backtrack()`` anywhere down in the parse tree will return to that position and continue there. (This is ported over the old prototype). Example: export type test = unit { a: bytes &length=4; foo: Foo &try; bar: Bar; b: bytes &length=6; on %done { print self; } }; type Foo = unit { a: int8 { print "Foo.a", self; } b: int8 { print "Backtracking"; self.backtrack(); } c: int8 { print "Foo.c", self; } }; type Bar = unit { a: int8 { print "Bar.a", self; } b: int8 { print "Bar.b", self; } c: int8 { print "Bar.c", self; } }; # printf '1234\001\002\003567890' | pac-driver backtrack.pac2 Foo.a <a=1, b=(not set), c=(not set)> Backtracking Bar.a <a=1, b=(not set), c=(not set)> Bar.b <a=1, b=2, c=(not set)> Bar.c <a=1, b=2, c=3> <a=1234, foo=(Null), bar=<a=1, b=2, c=3>, b=567890> Closes #25.
rsmmr
added a commit
that referenced
this issue
Dec 10, 2020
* origin/topic/robin/gh-25-backtrack: Fix Sphinx helper script that emits command lines. Add support for manual backtracking to Spicy. Support &eod for vector parsing.
rsmmr
added a commit
that referenced
this issue
Dec 10, 2020
* origin/topic/robin/gh-25-backtrack: Fix Sphinx helper script that emits command lines. Add support for manual backtracking to Spicy. Support &eod for vector parsing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Parse attributes:
&try
Unit methods
backtrack
Note: Make sure backtracking from an
%error
hook continues parsing.Old tests in
backtrack*
in https://github.com/rsmmr/hilti/tree/master/tests/spicy/unitThe text was updated successfully, but these errors were encountered: