[erlang-questions] yecc subpattern issue
Phil Pirozhkov
pirj@REDACTED
Fri Dec 26 23:50:13 CET 2008
Hi!
Having issues with yecc (leex works 100% fine)
For a
l
the following rules doesn't work, and they work perfectly fine for
{for a in b}{a}{a}{end}
https://github.com/pirj/ryan/tree/master/src/retem/retem_parse.yrl
I expect a single
for_block -> '{' for identifier in identifier '}' blocks end : {for, remove_id('$3'), '$5', ['$7']}.
is enough, but this rule doesn't seem to work at all.
for_block -> '{' for identifier in identifier '}' block end : {for, remove_id('$3'), '$5', ['$7']}.
works fine
Is there a need for an additional level of abstraction in this case?
leex output for "{for a in b}{a}{a}{end}" is:
[{'{'},
{for},
{identifier,a},
{in},
{identifier,b},
{'}'},
{'{'},
{identifier,a},
{'}'},
{'{'},
{identifier,a},
{'}'},
{'{'},
{endc},
{'}'}]
a single occurency of
{'{'},
{identifier,a},
{'}'},
is treated as 'block' by yecc, and the whole sequence results in
[{for,a,{identifier,b},{identifier,a}}]
but
{'{'},
{identifier,a},
{'}'},
{'{'},
{identifier,a},
{'}'},
isn't parsed as 'blocks', and results in exception:
exception error: no match of right hand side value
{error,{a,retem_parse,
["syntax error before: ",["identifier"]]}}
Why?
Is there a cure?
Cheers, Phil
More information about the erlang-questions
mailing list