class XPathParser token Number Literal Operator NameTest AxisName NodeType FunctionName VariableReference start LocationPath rule LocationPath : RelativeLocationPath | AbsoluteLocationPath ; AbsoluteLocationPath : '/' | '/' RelativeLocationPath ; RelativeLocationPath : Step { puts "Relative Location Path" } | RelativeLocationPath '/' Step ; Step : AxisSpecifier NodeTest Predicates { puts "Step" } ; AxisSpecifier : AxisName '::' { puts "AxisSpecifier" } ; OtherNodeTypes : 'comment' | 'text' | 'node' ; ##### here's the error NodeTest : NameTest { puts "NameTest" } | 'processing-instruction' '(' Literal ')' { puts "PI" } | OtherNodeTypes '(' ')' { puts "other" } ; Predicates : /* empty */ | Predicates Predicate { puts "Predicates" } Predicate : '[' ']' { puts "Predicate" } end ---- header require "tokenizer" ---- inner def parse( str ) @tokenizer = Tokenizer.new(str) do_parse end def next_token tok = @tokenizer.next_token if tok.nil? [false, '$'] else if tok.size == 1 then [tok[0], tok[0]] else tok end end end ---- footer if $0 == __FILE__ then $DEBUG=true src = "child::processing-instruction ( 'hallo' ) []" puts "parsing:" puts src XPathParser.new.parse(src) end