From a133b923a2247c1f6e6ba91ef2b94e778702e8cb Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 13 Aug 2014 01:28:43 +0200 Subject: [PATCH] Only emit extra T_SLASH tokens for "//". --- lib/oga/xpath/lexer.rl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/oga/xpath/lexer.rl b/lib/oga/xpath/lexer.rl index c968996..a594cce 100644 --- a/lib/oga/xpath/lexer.rl +++ b/lib/oga/xpath/lexer.rl @@ -30,6 +30,13 @@ module Oga # AXIS_EMIT_NODE = %w{descendant-or-self parent self} + ## + # Axes that require an extra T_SLASH token to be emitted. + # + # @return [Array] + # + AXIS_EMIT_EXTRA_SLASH = %w{descendant-or-self} + ## # @param [String] data The data to lex. # @@ -246,7 +253,9 @@ module Oga add_token(:T_LPAREN) add_token(:T_RPAREN) - add_token(:T_SLASH) unless te == eof + if AXIS_EMIT_EXTRA_SLASH.include?(value) and te != eof + add_token(:T_SLASH) + end end }