Explicit RibParseError, avoid expect
s in parsers and handle keywords properly
#950
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #943
Given below are some examples showing how this PR improved/fixed Rib behaviour from a user perspective
let let = 1;
was allowed before. This is not allowed anymore.{ err : "foo" }
wasn't allowed before. Now we allow it! Field names can beerr
, orok
or such keywords. The idea here is names inrecord
are more-or-less text itself. The only difference is they are not wrapped inquotes
following WASM-WAVE syntax.some1((x)
wasn't allowed before. Likewiseerr1
,none1
,match1
etall used to fail. Obviously users can write their own variants having such names.Fundamental changes
Proper Custom Error called
RibParseError
which can be used only if there is constraints that talks about conversion to combine's native StreamError. This is a very nice feature in combine, that we can have our own errors, but still consider everything as combine'sParseError
. There is more to it, but they are library detailsWith above, we remove all
expects
in parsers. It is to be notedcombine
libraries examples usesexpect
but pretty sure, its not giving the intended behavior.An identifier can be alpha numeric allowing
-
and_
but it shouldn't be any of the keywords such asif
,then
,else
.With the reduced backtracking, parser also got committed early resulting in prioritized parsers to fail without getting into
identifier
parser, such assome1
. The PR tries to solve it without bringing back the usage ofattempt
.The precise error messages are more precise due to these changes now.
let x = 1; let
result inInvalid identifier. let is a keyword
rather thanunexpected eof
and so on.Minor cleanups
With Grammar based fuzzing, or property based tests, we will tighten up all these behaviors even better.