I have the following PP grammar:
%skip space \s
%token lparan \(
%token rparan \)
%token period \.
%token identifier [A-Za-z][A-Za-z0-9_]*
#expression:
primaryExpression() |
expression() ::period:: <identifier>
#primaryExpression:
<identifier> |
::lparan:: expression() ::rparan::
I would like to parse expressions like the following:
Favourite.Food.Cake
(Favourite.Food.Cake)
(Favourite.Food).Cake
(Favourite).Food.Cake
There’s no problem with the first two expressions, but the last two produce the following error:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) ... Llk\Parser.php on line 389
which I assume is due to infinite recursion. What’s the best way to solve this problem?