ptal / oak

A typed parser generator embedded in Rust code for Parsing Expression Grammars
Apache License 2.0
143 stars 14 forks source link

Wrong error reporting for not syntactic predicate #89

Open ptal opened 8 years ago

ptal commented 8 years ago

For example take the grammar

predicate = (!"b" .)+ 

with the input b, it will output the wrong message:

unexpected `b`, expecting .

Other example could be find as well, this is because when logging errors we do not know we under in a not predicate.

ptal commented 8 years ago

This is described more in depth in:

Maidl, André Murbach, Sérgio Medeiros, Fabio Mascarenhas, and Roberto Ierusalimschy. “Error Reporting in Parsing Expression Grammars.” arXiv Preprint arXiv:1405.6646, 2014. http://arxiv.org/abs/1405.6646.

The strategy is quite simple, just ignore errors inside !p, and blame any failure on !p itself. From the example above we could obtain

unexpected `b`, expecting `!"b"`.

in a first time even if it could be improved later.