pointlander / peg

Peg, Parsing Expression Grammar, is an implementation of a Packrat parser generator.
BSD 3-Clause "New" or "Revised" License
1.02k stars 121 forks source link

Feat: Generate AST nodes only for rules that begin with a capital letter #99

Open dzpao opened 4 years ago

dzpao commented 4 years ago

This should close #98.

lolbinarycat commented 4 years ago

This really should be optional (i.e. a command line flag), otherwise it would break lots of things built with peg.

pointlander commented 4 years ago

Rule names that start with an underscore could be ignored.

lolbinarycat commented 4 years ago

No, that has the exact same problem, and just looks worse. I'm just saying that there needs to be some way to disable it, for the sake of backward compatability.

pointlander commented 4 years ago

The syntax: 'Rule <= Ignored' could be added. Rules that are not ignored would still be 'Rule <- NotIgnored'.

lolbinarycat commented 4 years ago

I guess that would work, but the syntax is non-obvious. I do like the idea of using capitalization, as it mirrors go's own behavior with (un)exported function. I simply think there needs to be a flag to turn it off.

lolbinarycat commented 4 years ago

flag implemented: https://github.com/lolbinarycat/peg/tree/ignoreCase-flag