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 be err, or ok or such keywords. The idea here is names in record are more-or-less text itself. The only difference is they are not wrapped in quotes following WASM-WAVE syntax.
some1((x) wasn't allowed before. Likewise err1, 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's ParseError. There is more to it, but they are library details
With above, we remove all expects in parsers. It is to be noted combine libraries examples uses expect 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 as if, then, else.
With the reduced backtracking, parser also got committed early resulting in prioritized parsers to fail without getting into identifier parser, such as some1. The PR tries to solve it without bringing back the usage of attempt.
The precise error messages are more precise due to these changes now. let x = 1; let result in Invalid identifier. let is a keyword rather than unexpected eof and so on.
Minor cleanups
With Grammar based fuzzing, or property based tests, we will tighten up all these behaviors even better.
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.