dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
534 stars 66 forks source link

qualifiedIdentifier in dgrammar.d is not defined #297

Open mw66 opened 4 years ago

mw66 commented 4 years ago

https://github.com/PhilippeSigaud/Pegged/blob/master/examples/dgrammar/src/pegged/examples/dgrammar.d#L60

ModuleDeclaration < "module" qualifiedIdentifier ";"

How Pegged detect / report such issue? I didn't see any error message.

Can problem like this (missing definition) contribute to the performance issue https://github.com/PhilippeSigaud/Pegged/issues/294

mw66 commented 4 years ago

BTW, is the Pegged syntax custom build?

e.g.

https://github.com/erikrose/parsimonious

the grammar are defined using =, while here in Pegged it's using < <- etc.

Maybe one way to debug the dgrammar.d is to make it work with parsimonious, e.g. after I change all < etc to =, I have problems using parsimonious, (after remove MacroDeclaration), I got:

parsimonious.exceptions.IncompleteParseError: Rule 'rules' matched in its entirety, but it didn't consume all the text. The non-matching portion of the text begins with '/ "static" "import" ' (line 35, column 45).
veelo commented 4 years ago

qualifiedIdentifier is a predefined parser, defined on https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/peg.d#L3513. Make sure you include that file.

BTW, is the Pegged syntax custom build?

PEG has no standardised syntax as far as I know, so different parser generators may use slightly different syntaxes. Pegged provides several extensions, including <.

Rule 'rules' matched in its entirety

There is no rules in dgrammar.d, so that must be specific to Parsimonious. I would guess that your translation to Parsimonious does not comply with the requirements of Parsimonious. I cannot help you there, as it's the first time I have heard of the program.

As explained in https://github.com/PhilippeSigaud/Pegged/issues/294#issuecomment-651708801, dgrammar is not a very good example. I appreciate your interest in getting it to work, but its value is quite limited IMHO.