in reply to Converting BNF for use in Parse::RecDescent

That's because you give Parse::RecDescent options for the x and y rules. PRD will, just like Perl regexes, try alternatives in order, left one first. So, if PRD has to choose between "y" and "y /AND/i y", it'll first do the y, and only if that alternative fails, it'll try the alternative.

You can fix this by requiring that after matching the SQL statement, it should match the end of the string. But, for efficiency, also reorganize the rules:

condition: x /OR/i x | x x: y /AND/i y | y
although this is still inefficient, as it may require backtracking.

Abigail