Hacker News new | ask | show | jobs
by chubot 1105 days ago
Nice article! In this sentence

... open parenthesis character is ambiguous in this context. To get around it they made their grammar more ambiguous and then enforced that the actual grammar was enforced in their tree builder.

I'd change the second "more ambiguous" to "more lenient"

i.e. lenient meaning "grammar accepts more strings", ambiguous meaning "grammar is invalid"

I have seen this issue in Python's grammar as well, and it's mitigated by the new PEG parser

1 comments

Ambigious does not mean invalid
For people who see parsing as model checking, ambiguity means something vastly different (inferior) to leniency.

Fast parsers that use a schema are also doing model checking.

Yes, technically it means "there's more than one derivation"

But Python's pgen rejects such grammars as invalid ... The other strategy is just to pick an arbitrary interpretation