Closed mingodad closed 2 years ago
@mingodad, thanks for the report. This is actually an intended behavior to match the behavior of most regex engines.
> cat bug.peg
start <- name1 / name2
name1 <- [^][a-z]
name2 <- [^2][a-z]
> peglint bug.peg
bug.peg:2:12: syntax error
Here is the output form PCRE2:
In order to implement the same behavior, I added !'^'
to Class
in the Bryan Ford's original PEG syntax.
Original: Class <- ’[’ (!’]’ Range)* ’]’ Spacing
cpp-peglib: Class <- ’[’ !'^' (!’]’ Range)* ’]’ Spacing
See this discussion https://github.com/ChrisHixon/chpeg/issues/1#issuecomment-1166246408 , bellow is the sample input using the possibly fixed
cpp-peglib
grammar:Input:
AST:
Proposed working grammar (manually extracted from peglib.h):