yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
880 stars 112 forks source link

Crash when there is a Cut operator which doesn't belong to a PrioritizedChoice operator #237

Closed kfsone closed 2 years ago

kfsone commented 2 years ago

The following grammar causes the playground to lock into an infinite loop:

p <- (a E)*
~E <- '\n' / !.
a <- 'x' '=' ↑ t   # << removing the cut solves the problem
t <- 'a' | 'b'
yhirose commented 2 years ago

@kfsone, thanks for the report, but I can't reproduce it on the playground.

image

Also I am not able to reproduce it with peglint either.

image
kfsone commented 2 years ago

Ah, sorry, try the input:

x=c

infinite-loop

yhirose commented 2 years ago

Thanks. I am now reproduce it.

yhirose commented 2 years ago

This is actually not a infinite loop problem. This is caused by a Cut operator which doesn't belong to a PrioritizedChoice operator. I changed the title.