From 4142504101f0632ed004ce9a8881c58603288765 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 22 Jul 2014 15:53:00 +0200 Subject: [PATCH] Revert "Lex XPath axes without a node test." Upon further investigation this change turned out to be useless. Nokogiri/libxml does not allow the use of long axes without tests, instead it ends up lexing/parsing such a value as a simple node test. This reverts commit f699b0d09720b4f337b4d7f1e3c80b5e299d3876. --- lib/oga/xpath/lexer.rl | 17 +++++++++-------- spec/oga/xpath/parser/axes_spec.rb | 15 --------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/lib/oga/xpath/lexer.rl b/lib/oga/xpath/lexer.rl index 82c801d..c968996 100644 --- a/lib/oga/xpath/lexer.rl +++ b/lib/oga/xpath/lexer.rl @@ -219,7 +219,11 @@ module Oga | 'parent' | 'preceding' | 'preceding-sibling' - | 'self'); + | 'self') '::'; + + action emit_axis_full { + emit(:T_AXIS, ts, te - 2) + } # Short Axes # @@ -299,13 +303,10 @@ module Oga '[' => { add_token(:T_LBRACK) }; ']' => { add_token(:T_RBRACK) }; - string => emit_string; - integer => emit_integer; - float => emit_float; - - axis_full => { emit(:T_AXIS, ts, te) }; - axis_full '::' => { emit(:T_AXIS, ts, te - 2) }; - + string => emit_string; + integer => emit_integer; + float => emit_float; + axis_full => emit_axis_full; axis_short => emit_axis_short; identifier => emit_identifier; *|; diff --git a/spec/oga/xpath/parser/axes_spec.rb b/spec/oga/xpath/parser/axes_spec.rb index 77920e2..ba71243 100644 --- a/spec/oga/xpath/parser/axes_spec.rb +++ b/spec/oga/xpath/parser/axes_spec.rb @@ -44,21 +44,6 @@ describe Oga::XPath::Parser do ) end - example 'parse the descendant-or-self axis without a test' do - parse_xpath('/descendant-or-self').should == s( - :absolute_path, - s(:axis, 'descendant-or-self') - ) - end - - example 'parse the descendant-or-self axis followed by an attribute axis' do - parse_xpath('/descendant-or-self/attribute::foo').should == s( - :absolute_path, - s(:axis, 'descendant-or-self'), - s(:axis, 'attribute', s(:test, nil, 'foo')) - ) - end - example 'parse the following axis' do parse_xpath('/following::A').should == s( :absolute_path,