From: Michael Neumann Date: 2001-04-18T06:21:38+09:00 Subject: [ruby-talk:13775] Problems with racc rule definitions Hi, Following racc-rule raises an error during parsing (not during 'racc parser.y'), and I don't know why. It seems to me that racc is very limited. * and ? would be nice :) NodeType can be 'comment', 'text', 'processing-instruction' or 'node'. ###### token NameTest NodeType Literal rule NodeTest : NameTest | 'processing-instruction' '(' Literal ')' | NodeType '(' ')' ; end ####### My first thought was that the error is raised because NodeType contains "processing-instruction'. But if the error is also there if I write: NodeTest : NameTest | 'processing-instruction' '(' Literal ')' | 'comment' '(' ')' | 'text' '(' ')' | 'node' '(' ')' ; The solution I've found, which works is the following: NodeTest : NameTest | NodeType '(' Literal ')' { if val[0] != "processing-instruction" then yyerror raise ArgumentError, "yyerror failed" else puts "ok" end } | NodeType '(' ')' { if val[0] == "processing-instruction" then yyerror raise ArgumentError, "yyerror failed" else puts "ok" end } ; #### Is there another way to do it more elegant? Thanks in advance. Regards Michael -- Michael Neumann merlin.zwo InfoDesign GmbH http://www.merlin-zwo.de