Lexing of explicit negative/positive XPath numbers

This commit is contained in:
Yorick Peterse committed 2014-08-26 20:21:30 +02:00
1 parent 8295fa5783
commit bcd138a15a
3 files changed
+28 -2

No files matched your search

+2 -2
View File
@@ -178,8 +178,8 @@ module Oga
# instead lexes them separately so that we can convert the values to
# the corresponding Ruby types (Fixnum and Float).
integer = digit+;
float = digit+ ('.' digit+)*;
integer = ('-' | '+')* digit+;
float = ('-' | '+')* digit+ ('.' digit+)*;
action emit_integer {
value = slice_input(ts, te).to_i
+13
View File
@@ -0,0 +1,13 @@
require 'spec_helper'
describe Oga::XPath::Lexer do
context 'floats' do
example 'lex a float' do
lex_xpath('10.0').should == [[:T_FLOAT, 10.0]]
end
example 'lex a negative float' do
lex_xpath('-10.0').should == [[:T_FLOAT, -10.0]]
end
end
end
+13
View File
@@ -0,0 +1,13 @@
require 'spec_helper'
describe Oga::XPath::Lexer do
context 'integers' do
example 'lex an integer' do
lex_xpath('10').should == [[:T_INT, 10]]
end
example 'lex a negative integer' do
lex_xpath('-10').should == [[:T_INT, -10]]
end
end
end