Hoeloe
Hoeloe

Reputation: 650

LPEG - "Rule may be left-recursive" error, despite being a terminable grammar

I'm trying to use LPEG to build a preprocessor for GLSL. I've managed to get #define and #undef statements working no problem, but my issues comes when trying to work with #ifdef statements.

My thought was that I could build a rule that would encapsulate a shader, bordered by #ifdef and #endif statements, like so:

S -> include | define | ifdef | code
ifdef -> "#ifdef" + var + S + "#endif"

Clearly this grammar is terminable, as the ifdef rule requires capturing #ifdef and the macro name before the recursive call. However, LPEG disagrees, claiming this rule "may be left recursive".

Does anyone know what I can do about this?

Thanks.

Upvotes: 1

Views: 165

Answers (0)

Related Questions