1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/date/delta/parser.{ry,rb}: fixed a bug of token scanner.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tadf 2010-11-22 22:59:48 +00:00
parent bacd547858
commit b828fb85dd
3 changed files with 11 additions and 5 deletions

View file

@ -1,3 +1,7 @@
Tue Nov 23 07:57:31 2010 Tadayoshi Funaba <tadf@dotrb.org>
* lib/date/delta/parser.{ry,rb}: fixed a bug of token scanner.
Tue Nov 23 07:29:24 2010 Tadayoshi Funaba <tadf@dotrb.org>
* complex.c, rational.c ({nucomp,nurat}_expt): added a check.

View file

@ -13,7 +13,7 @@ class Date
class Parser < Racc::Parser
module_eval <<'..end parser.ry modeval..id43bff5dec9', 'parser.ry', 42
module_eval <<'..end parser.ry modeval..idf2987de166', 'parser.ry', 42
def lookup(str)
t = str.downcase
@ -28,7 +28,8 @@ module_eval <<'..end parser.ry modeval..id43bff5dec9', 'parser.ry', 42
until str.empty?
case str
when /\A\s+/
when /\AP(\d+y)?(\d+m)?(\d+d)?t?(\d+h)?(\d+m)?(\d+s)?(\d+w)?/i
when /\Ap\d+[ymdhsw]/i
/\Ap(\d+y)?(\d+m)?(\d+d)?t?(\d+h)?(\d+m)?(\d+s)?(\d+w)?/i =~ str
y, m, d, h, min, s, w =
[$1, $2, $3, $4, $5, $6, $7].collect{|x| x.to_i}
y *= UNITS4KEY['years']
@ -56,7 +57,7 @@ module_eval <<'..end parser.ry modeval..id43bff5dec9', 'parser.ry', 42
@q.shift
end
..end parser.ry modeval..id43bff5dec9
..end parser.ry modeval..idf2987de166
##### racc 1.4.5 generates ###

View file

@ -1,4 +1,4 @@
# parser.ry: Written by Tadayoshi Funaba 2006,2008,2009 -*- ruby -*-
# parser.ry: Written by Tadayoshi Funaba 2006,2008-2010 -*- ruby -*-
class Date::Delta::Parser
@ -53,7 +53,8 @@ class Date::Delta::Parser
until str.empty?
case str
when /\A\s+/
when /\AP(\d+y)?(\d+m)?(\d+d)?t?(\d+h)?(\d+m)?(\d+s)?(\d+w)?/i
when /\Ap\d+[ymdhsw]/i
/\Ap(\d+y)?(\d+m)?(\d+d)?t?(\d+h)?(\d+m)?(\d+s)?(\d+w)?/i =~ str
y, m, d, h, min, s, w =
[$1, $2, $3, $4, $5, $6, $7].collect{|x| x.to_i}
y *= UNITS4KEY['years']