Thread overview |
---|
October 31, 2019 Why Dlang use parsing expression grammar (PEG) parser not BNF? | ||||
---|---|---|---|---|
| ||||
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? |
November 01, 2019 Re: Why Dlang use parsing expression grammar (PEG) parser not BNF? | ||||
---|---|---|---|---|
| ||||
Posted in reply to lili | 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. |
November 01, 2019 Re: Why Dlang use parsing expression grammar (PEG) parser not BNF? | ||||
---|---|---|---|---|
| ||||
Posted in reply to lili | 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? IIRC the PEG for D is not complete. You have an EBNF here https://libdparse.dlang.io/grammar.html, which you can use to feed a library generating the parser. Note however that the lexical part is missing (so the regex-like for numbers, literals, etc.). |
Copyright © 1999-2021 by the D Language Foundation