You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are sometimes sure that if a rule fails, the program can't be correct. It often happens after a specific keyword has been encountered. For example in Rust, a let must be followed by a declaration:
let-decl = "let" decl ";"
If we parse the "let" but that decl fail, it's useless to backtrack and can put a context-sensitive message here:
let-decl =
"let" decl ";"
\ "let" decl !";" { "A let declaration must be terminated by a semi-colon." }
\ "let" .* { "A let must be followed by a declaration." }
We use the \ character because it's a bit like the dual of the choice: if the rule succeed it will fail (instead of succeed).
The text was updated successfully, but these errors were encountered:
This approach is different from existing error reporting mechanism, it leaves the user to report himself the error (which is often desirable in compiler—for better error messages) instead of trying to generate automatically all the errors. Note that we still generate errors if the user didn't specify anything so it lets the user free to improve the grammar later.
We are sometimes sure that if a rule fails, the program can't be correct. It often happens after a specific keyword has been encountered. For example in Rust, a let must be followed by a declaration:
If we parse the "let" but that decl fail, it's useless to backtrack and can put a context-sensitive message here:
We use the
\
character because it's a bit like the dual of the choice: if the rule succeed it will fail (instead of succeed).The text was updated successfully, but these errors were encountered: