diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-22 22:59:48 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-11-22 22:59:48 +0000 |
commit | b828fb85dda5970334d42f1a0b542c8d3ebf825b (patch) | |
tree | 0aa2418456daf77320ddce04e1eb54ebbe4cd521 /lib/date | |
parent | bacd54785856a7d7a7dd3ea995b9aa6f9c56a3da (diff) | |
download | ruby-b828fb85dda5970334d42f1a0b542c8d3ebf825b.tar.gz |
* 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
Diffstat (limited to 'lib/date')
-rw-r--r-- | lib/date/delta/parser.rb | 7 | ||||
-rw-r--r-- | lib/date/delta/parser.ry | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/lib/date/delta/parser.rb b/lib/date/delta/parser.rb index 7efe29f4c2..459d77a572 100644 --- a/lib/date/delta/parser.rb +++ b/lib/date/delta/parser.rb @@ -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 ### diff --git a/lib/date/delta/parser.ry b/lib/date/delta/parser.ry index 84d4c22c3c..4de8aa1e46 100644 --- a/lib/date/delta/parser.ry +++ b/lib/date/delta/parser.ry @@ -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'] |