yhirose / cpp-peglib

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

vs.choice() always returns 0 when %whitespace is defined. #266

Closed CameronTofer closed 1 year ago

CameronTofer commented 1 year ago

Hi, if I define %whitespace then prioritized choices always return 0.

auto grammar = R"( type <- 'string' / 'int' / 'double' %whitespace <- [ \t\r\n]* )"

...

parser["type"] = [](const SemanticValues& vs) { return vs.choice(); // choice and choice count are always 0. works if %whitespace line is deleted };

am I missing something?

yhirose commented 1 year ago

@CameronTofer thanks for the report. It looks a bug. I'll look into it when I have time. Thanks!