The modified grammar is not LL(1)
anymore. As a consequence the simple recursive descent parser implemented by Doctrine requires backtracking.
In this case, you need to make sure that ::Value()
can backtrack, ie. trigger an exception and reset the parsing to the position it was in before entering ::Value()
. You catch this exception and just ignore it in ::Values()
as soon as you already have one valid value.
That requires to be able to seek in the lexer, and I don't know how practical it is. AbstractLexer
is quite a bit weird.
Edit: The easiest way forward would be to keep the grammar in a LL(1) form. One way of doing that is to move the parenthesis inside Values
:
Values ::= "(" [Array | Value {"," Value}* [","] ] ")"