-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] Adding date to stdlib using rubysl-date.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
- 9.0.5.0
- 9.0.4.0
- 9.0.3.0
- 9.0.1.0
- 9.0.0.0
- 9.0.0.0.rc2
- 9.0.0.0.rc1
- 9.0.0.0.pre2
Showing
12 changed files
with
4,032 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Copyright (c) 2013, Brian Shirai | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the library nor the names of its contributors may be | ||
used to endorse or promote products derived from this software without | ||
specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "rubysl/date" |
Large diffs are not rendered by default.
Oops, something went wrong.
301 changes: 301 additions & 0 deletions
301
lib/ruby/truffle/rubysl/rubysl-date/lib/date/delta/parser.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
# | ||
# DO NOT MODIFY!!!! | ||
# This file is automatically generated by racc 1.4.5 | ||
# from racc grammer file "parser.ry". | ||
# | ||
|
||
require 'racc/parser' | ||
|
||
|
||
class Date | ||
|
||
class Delta | ||
|
||
class Parser < Racc::Parser | ||
|
||
module_eval <<'..end parser.ry modeval..id43bff5dec9', 'parser.ry', 42 | ||
def lookup(str) | ||
t = str.downcase | ||
k = UNITS4KEY[t] | ||
return [:UNIT, k] if k | ||
return [:AND, nil] if t == 'and' | ||
return [:UNKNOWNWORD, nil] | ||
end | ||
def parse(str) | ||
@q = [] | ||
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 | ||
y, m, d, h, min, s, w = | ||
[$1, $2, $3, $4, $5, $6, $7].collect{|x| x.to_i} | ||
y *= UNITS4KEY['years'] | ||
m *= UNITS4KEY['months'] | ||
d *= UNITS4KEY['days'] | ||
h *= UNITS4KEY['hours'] | ||
min *= UNITS4KEY['minutes'] | ||
s *= UNITS4KEY['seconds'] | ||
w *= UNITS4KEY['weeks'] | ||
@q.push [:DURATION, y + m + d + h + min + s + w] | ||
when /\A\d+/ | ||
@q.push [:DIGITS, $&.to_i] | ||
when /\A[a-z]+/i | ||
@q.push lookup($&) | ||
when /\A.|\n/ | ||
@q.push [$&, $&] | ||
end | ||
str = $' | ||
end | ||
@q.push [false, false] | ||
do_parse | ||
end | ||
def next_token | ||
@q.shift | ||
end | ||
..end parser.ry modeval..id43bff5dec9 | ||
|
||
##### racc 1.4.5 generates ### | ||
|
||
racc_reduce_table = [ | ||
0, 0, :racc_error, | ||
1, 16, :_reduce_none, | ||
1, 17, :_reduce_none, | ||
1, 17, :_reduce_none, | ||
3, 17, :_reduce_4, | ||
3, 17, :_reduce_5, | ||
3, 17, :_reduce_6, | ||
3, 17, :_reduce_7, | ||
3, 17, :_reduce_8, | ||
3, 17, :_reduce_9, | ||
3, 17, :_reduce_10, | ||
2, 17, :_reduce_11, | ||
2, 17, :_reduce_12, | ||
3, 17, :_reduce_13, | ||
2, 18, :_reduce_14, | ||
0, 20, :_reduce_15, | ||
1, 20, :_reduce_none, | ||
1, 19, :_reduce_none ] | ||
|
||
racc_reduce_n = 18 | ||
|
||
racc_shift_n = 32 | ||
|
||
racc_action_table = [ | ||
13, 14, 15, 16, 17, 18, 19, 4, 27, 23, | ||
8, 9, 1, 4, 25, 2, 8, 9, 1, 4, | ||
24, 2, 8, 9, 1, 4, 21, 2, 8, 9, | ||
1, 4, 11, 2, 8, 9, 1, 4, 26, 2, | ||
8, 9, 1, 4, nil, 2, 8, 9, 1, 4, | ||
nil, 2, 8, 9, 1, nil, nil, 2, 13, 14, | ||
15, 16, 17, 18, 19, 13, 14, 15, 13, 14, | ||
15, 13, 14, 15, 13, 14, 15 ] | ||
|
||
racc_action_check = [ | ||
10, 10, 10, 10, 10, 10, 10, 17, 15, 10, | ||
17, 17, 17, 18, 13, 17, 18, 18, 18, 4, | ||
11, 18, 4, 4, 4, 1, 9, 4, 1, 1, | ||
1, 8, 3, 1, 8, 8, 8, 19, 14, 8, | ||
19, 19, 19, 0, nil, 19, 0, 0, 0, 16, | ||
nil, 0, 16, 16, 16, nil, nil, 16, 5, 5, | ||
5, 5, 5, 5, 5, 30, 30, 30, 28, 28, | ||
28, 29, 29, 29, 31, 31, 31 ] | ||
|
||
racc_action_pointer = [ | ||
37, 19, nil, 32, 13, 55, nil, nil, 25, 13, | ||
-3, 20, nil, 4, 28, -2, 43, 1, 7, 31, | ||
nil, nil, nil, nil, nil, nil, nil, nil, 65, 68, | ||
62, 71 ] | ||
|
||
racc_action_default = [ | ||
-18, -18, -17, -18, -18, -1, -2, -3, -18, -15, | ||
-18, -18, -12, -18, -18, -18, -18, -18, -18, -18, | ||
-11, -16, -14, -13, 32, -10, -8, -9, -4, -5, | ||
-6, -7 ] | ||
|
||
racc_goto_table = [ | ||
5, 10, 3, 22, 12, nil, nil, nil, 20, nil, | ||
nil, nil, nil, nil, nil, nil, 28, 29, 30, 31 ] | ||
|
||
racc_goto_check = [ | ||
2, 2, 1, 5, 2, nil, nil, nil, 2, nil, | ||
nil, nil, nil, nil, nil, nil, 2, 2, 2, 2 ] | ||
|
||
racc_goto_pointer = [ | ||
nil, 2, 0, nil, nil, -6 ] | ||
|
||
racc_goto_default = [ | ||
nil, nil, nil, 6, 7, nil ] | ||
|
||
racc_token_table = { | ||
false => 0, | ||
Object.new => 1, | ||
:UNARY => 2, | ||
"^" => 3, | ||
"*" => 4, | ||
"/" => 5, | ||
"+" => 6, | ||
"," => 7, | ||
:AND => 8, | ||
"-" => 9, | ||
:DIGITS => 10, | ||
"(" => 11, | ||
")" => 12, | ||
:UNIT => 13, | ||
:DURATION => 14 } | ||
|
||
racc_use_result_var = true | ||
|
||
racc_nt_base = 15 | ||
|
||
Racc_arg = [ | ||
racc_action_table, | ||
racc_action_check, | ||
racc_action_default, | ||
racc_action_pointer, | ||
racc_goto_table, | ||
racc_goto_check, | ||
racc_goto_default, | ||
racc_goto_pointer, | ||
racc_nt_base, | ||
racc_reduce_table, | ||
racc_token_table, | ||
racc_shift_n, | ||
racc_reduce_n, | ||
racc_use_result_var ] | ||
|
||
Racc_token_to_s_table = [ | ||
'$end', | ||
'error', | ||
'UNARY', | ||
'"^"', | ||
'"*"', | ||
'"/"', | ||
'"+"', | ||
'","', | ||
'AND', | ||
'"-"', | ||
'DIGITS', | ||
'"("', | ||
'")"', | ||
'UNIT', | ||
'DURATION', | ||
'$start', | ||
'stmt', | ||
'expr', | ||
'time', | ||
'iso', | ||
'unit'] | ||
|
||
Racc_debug_parser = false | ||
|
||
##### racc system variables end ##### | ||
|
||
# reduce 0 omitted | ||
|
||
# reduce 1 omitted | ||
|
||
# reduce 2 omitted | ||
|
||
# reduce 3 omitted | ||
|
||
module_eval <<'.,.,', 'parser.ry', 18 | ||
def _reduce_4( val, _values, result ) | ||
result += val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 19 | ||
def _reduce_5( val, _values, result ) | ||
result += val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 20 | ||
def _reduce_6( val, _values, result ) | ||
result += val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 21 | ||
def _reduce_7( val, _values, result ) | ||
result -= val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 22 | ||
def _reduce_8( val, _values, result ) | ||
result *= val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 23 | ||
def _reduce_9( val, _values, result ) | ||
result /= val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 24 | ||
def _reduce_10( val, _values, result ) | ||
result **= val[2] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 25 | ||
def _reduce_11( val, _values, result ) | ||
result = -val[1] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 26 | ||
def _reduce_12( val, _values, result ) | ||
result = +val[1] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 27 | ||
def _reduce_13( val, _values, result ) | ||
result = val[1] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 30 | ||
def _reduce_14( val, _values, result ) | ||
result = val[0] * val[1] | ||
result | ||
end | ||
.,., | ||
|
||
module_eval <<'.,.,', 'parser.ry', 33 | ||
def _reduce_15( val, _values, result ) | ||
result = 1 | ||
result | ||
end | ||
.,., | ||
|
||
# reduce 16 omitted | ||
|
||
# reduce 17 omitted | ||
|
||
def _reduce_none( val, _values, result ) | ||
result | ||
end | ||
|
||
end # class Parser | ||
|
||
end # class Delta | ||
|
||
end # class Date |
84 changes: 84 additions & 0 deletions
84
lib/ruby/truffle/rubysl/rubysl-date/lib/date/delta/parser.ry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# parser.ry: Written by Tadayoshi Funaba 2006,2008,2009 -*- ruby -*- | ||
|
||
class Date::Delta::Parser | ||
|
||
prechigh | ||
nonassoc UNARY | ||
left '^' | ||
left '*' '/' | ||
left '+' ',' AND '-' | ||
preclow | ||
|
||
rule | ||
|
||
stmt : expr | ||
; | ||
|
||
expr : time | ||
| iso | ||
| expr '+' expr {result += val[2]} | ||
| expr ',' expr {result += val[2]} | ||
| expr AND expr {result += val[2]} | ||
| expr '-' expr {result -= val[2]} | ||
| expr '*' DIGITS {result *= val[2]} | ||
| expr '/' DIGITS {result /= val[2]} | ||
| expr '^' DIGITS {result **= val[2]} | ||
| '-' expr =UNARY {result = -val[1]} | ||
| '+' expr =UNARY {result = +val[1]} | ||
| '(' expr ')' {result = val[1]} | ||
; | ||
|
||
time : DIGITS unit {result = val[0] * val[1]} | ||
; | ||
|
||
unit : {result = 1} | UNIT | ||
; | ||
|
||
iso : DURATION | ||
; | ||
|
||
---- header ---- | ||
---- inner ---- | ||
|
||
def lookup(str) | ||
t = str.downcase | ||
k = UNITS4KEY[t] | ||
return [:UNIT, k] if k | ||
return [:AND, nil] if t == 'and' | ||
return [:UNKNOWNWORD, nil] | ||
end | ||
|
||
def parse(str) | ||
@q = [] | ||
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 | ||
y, m, d, h, min, s, w = | ||
[$1, $2, $3, $4, $5, $6, $7].collect{|x| x.to_i} | ||
y *= UNITS4KEY['years'] | ||
m *= UNITS4KEY['months'] | ||
d *= UNITS4KEY['days'] | ||
h *= UNITS4KEY['hours'] | ||
min *= UNITS4KEY['minutes'] | ||
s *= UNITS4KEY['seconds'] | ||
w *= UNITS4KEY['weeks'] | ||
@q.push [:DURATION, y + m + d + h + min + s + w] | ||
when /\A\d+/ | ||
@q.push [:DIGITS, $&.to_i] | ||
when /\A[a-z]+/i | ||
@q.push lookup($&) | ||
when /\A.|\n/ | ||
@q.push [$&, $&] | ||
end | ||
str = $' | ||
end | ||
@q.push [false, false] | ||
do_parse | ||
end | ||
|
||
def next_token | ||
@q.shift | ||
end | ||
|
||
---- footer ---- |
1,328 changes: 1,328 additions & 0 deletions
1,328
lib/ruby/truffle/rubysl/rubysl-date/lib/date/format.rb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "rubysl/date/version" | ||
require "rubysl/date/date" |
1,852 changes: 1,852 additions & 0 deletions
1,852
lib/ruby/truffle/rubysl/rubysl-date/lib/rubysl/date/date.rb
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
lib/ruby/truffle/rubysl/rubysl-date/lib/rubysl/date/version.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module RubySL | ||
module Date | ||
VERSION = "2.0.9" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters