Why Dlang use parsing expression grammar (PEG) parser not BNF?

Dennis dkorpel at gmail.com
Fri Nov 1 09:07:52 UTC 2019


On Thursday, 31 October 2019 at 08:40:42 UTC, lili wrote:
> Hi:
>    I want implementation Lua on D, I find that a PEG parser 
> https://github.com/PhilippeSigaud/Pegged
>    why do not use BNF parser. Is PEG better than BNF?

The readme has a link to the reference article:

https://bford.info/pub/lang/peg

Which says in the abstract:

> The power of generative grammars to express ambiguity is 
> crucial to their original purpose of modelling natural 
> languages, but this very power makes it unnecessarily difficult 
> both to express and to parse machine-oriented languages using 
> CFGs. Parsing Expression Grammars (PEGs) provide an 
> alternative, recognition-based formal foundation for describing 
> machine-oriented syntax, which solves the ambiguity problem by 
> not introducing ambiguity in the first place.



More information about the Digitalmars-d-learn mailing list