Closed khchen closed 5 years ago
That's not without problems: because the NPeg grammar is parsed by the Nim compiler, Nim's operator precedence applies. In PEGs, concatenation has precedence over ordered choice, which matches nicely with the Nim *
and |
operators. (In the original PEG syntax, the symbol for ordered choice is /
, but that also has wrong precedence, thus the |
) The %
operator is not yet used in NPeg and has a higher precedence then |
, so theoretically that could replace concatenation, although I'm not sure if that is any better.
I think the only way to get rid of the current notation is to parse PEGs from strings instead of from Nim code; that would allow for any syntax, but has its downsides as well (more complex code, breaks syntax highlighting, and makes Nim code embedded impossible or non-trivial)
I like this module very much! Thanks for your effort.
However, when I try to use it in my projects, I found it is hard to read the PEG grammar because that concatenation and matches 0 or more times use the same symbol
*
.Is it possible to use another symbol for concatenation, for example:
~
, or others?