In mail "[ruby-talk:13807] Re: Problems with racc rule definitions"
Michael Neumann <neumann / s-direktnet.de> wrote:
> > > Following racc-rule raises an error during parsing (not during 'racc parser.y'),
> > > and I don't know why.
Ahh, I'm sorry, I did not take the point of your question.
Yes, there's no way to branch parser action by semantic value.
racc know about only symbol. Maybe your "if val[0] == ..." way is
right. Katsuhiro Ueno's xmlscan library uses also racc, and his
code is:
| NodeType '(' nodeTestArg ')'
{
nodetype = val[0]
arg = val[2]
if arg and nodetype != 'processing-instruction' then
raise CompileError,
"nodetest #{nodetype}() requires no argument"
end
[ nodetype, arg || false, false ]
}
Minero Aoki