Failure to parse consecutive predicates
Created by: badeball
Hi, Yorick
How are you doing?
I think I've found a bug in your application. See the following output.
irb(main):012:0> Oga::XPath::Parser.new("//foo[2][2]").parse
LL::ParserError: Received T_INT but there's nothing left to parse
from /home/jonas/.gem/ruby/2.3.3/gems/ruby-ll-2.1.2/lib/ll/driver.rb:15:in `parser_error'
from /home/jonas/.gem/ruby/2.3.3/gems/oga-2.10/lib/oga/xpath/parser.rb:280:in `block in each_token'
from /home/jonas/.gem/ruby/2.3.3/gems/oga-2.10/lib/oga/xpath/lexer.rb:2557:in `add_token'
from /home/jonas/.gem/ruby/2.3.3/gems/oga-2.10/lib/oga/xpath/lexer.rb:2193:in `advance'
from /home/jonas/.gem/ruby/2.3.3/gems/oga-2.10/lib/oga/xpath/parser.rb:277:in `each_token'
from (irb):12:in `parse'
from (irb):12
from /home/jonas/.rubies/ruby-2.3.3/bin/irb:11:in `<main>'
It's maybe easy to think that consecutive predicates are really just boolean conditions that are AND-ed together, but they're not. Consider the above mentioned query. It is not equivalent to //foo[position() = 2 and position() = 2]
. It actually selects the 2. foo that is the 2. child of its parent.