parser 2.4.0.0 → 2.4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +4 -4
- data/CHANGELOG.md +18 -27
- data/Rakefile +7 -2
- data/doc/AST_FORMAT.md +2 -37
- data/lib/parser/all.rb +1 -0
- data/lib/parser/builders/default.rb +18 -5
- data/lib/parser/current.rb +12 -3
- data/lib/parser/lexer.rl +4 -9
- data/lib/parser/lexer/literal.rb +1 -1
- data/lib/parser/macruby.y +20 -10
- data/lib/parser/meta.rb +4 -4
- data/lib/parser/ruby18.y +20 -10
- data/lib/parser/ruby19.y +20 -10
- data/lib/parser/ruby20.y +20 -10
- data/lib/parser/ruby21.y +10 -5
- data/lib/parser/ruby22.y +10 -5
- data/lib/parser/ruby23.y +10 -5
- data/lib/parser/ruby24.y +10 -5
- data/lib/parser/ruby25.y +2362 -0
- data/lib/parser/rubymotion.y +20 -10
- data/lib/parser/runner.rb +5 -0
- data/lib/parser/runner/ruby_rewrite.rb +1 -1
- data/lib/parser/source/buffer.rb +1 -1
- data/lib/parser/source/comment.rb +2 -3
- data/lib/parser/source/comment/associator.rb +8 -1
- data/lib/parser/source/rewriter.rb +4 -0
- data/lib/parser/version.rb +1 -1
- data/parser.gemspec +6 -5
- data/test/helper.rb +1 -1
- data/test/parse_helper.rb +7 -1
- data/test/racc_coverage_helper.rb +2 -1
- data/test/test_base.rb +1 -1
- data/test/test_current.rb +2 -0
- data/test/test_encoding.rb +6 -6
- data/test/test_lexer.rb +68 -30
- data/test/test_parse_helper.rb +3 -3
- data/test/test_parser.rb +136 -6
- data/test/test_source_comment_associator.rb +90 -0
- data/test/test_source_map.rb +1 -1
- metadata +15 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d6d941bf457d9da60c736d24713d5aa983a961f
|
4
|
+
data.tar.gz: fdd23f47888aff4b9845ef491a1cda609c3df29d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34386bd586b1ea4bc287f36141794c8c69ede511cb7a922c9807dae21375a551dcabdd5fb1aa377c16e3ec7d11abaecfed325850497110f29c9eb49cb8742e0c
|
7
|
+
data.tar.gz: 17af7b4e7a0a8c6d69d51078a5e0173104af739b73c90061721b8f39603e44aed783ff600998818218b57bfd09af1bd1f2817fd8fce7488f550ac29d697e99df
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
dist: trusty
|
1
2
|
language: ruby
|
2
3
|
rvm:
|
3
4
|
- 1.9.2
|
@@ -5,18 +6,17 @@ rvm:
|
|
5
6
|
- 2.0.0
|
6
7
|
- 2.2.5
|
7
8
|
- 2.3.1
|
9
|
+
- 2.4.0
|
8
10
|
- ruby-head
|
9
|
-
- jruby-
|
10
|
-
- jruby-19mode
|
11
|
+
- jruby-9.1.14.0
|
11
12
|
- rbx-2
|
12
13
|
matrix:
|
13
14
|
allow_failures:
|
14
15
|
- rvm: ruby-head
|
15
16
|
- rvm: rbx-2
|
16
17
|
before_install:
|
17
|
-
- gem
|
18
|
+
- gem install bundler
|
18
19
|
- bundle --version
|
19
|
-
- gem update --system 2.6.6
|
20
20
|
- gem --version
|
21
21
|
script:
|
22
22
|
- bundle exec rake test_cov
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
+
Not released (2017-11-13)
|
5
|
+
-------------------------
|
6
|
+
|
7
|
+
API modifications:
|
8
|
+
* parser/current: update for 2.3.4 release. (whitequark)
|
9
|
+
* parser/current: update for Ruby 2.1.10 and 2.2.7. (Koichi ITO)
|
10
|
+
|
11
|
+
Features implemented:
|
12
|
+
* Allow rescue/else/ensure inside do/end blocks. [Feature #12906] (Ilya Bylich)
|
13
|
+
* ruby25.y: branch parser. (Ilya Bylich)
|
14
|
+
|
15
|
+
Bugs fixed:
|
16
|
+
* Source::Comment::Associator: skip -*- magic comments -*-. (Denis Defreyne)
|
17
|
+
* lexer.rl: "- 5": allow whitespace after tUNARY_NUM. (whitequark)
|
18
|
+
* *ruby*.y, Builders::Default: "+5": don't lose location of the "+". (whitequark)
|
19
|
+
* ruby-rewrite: allow passing paths to --load. (whitequark)
|
20
|
+
* builders/default: "def x; else; end": don't crash. (whitequark)
|
21
|
+
|
4
22
|
v2.4.0.0 (2017-02-07)
|
5
23
|
---------------------
|
6
24
|
|
@@ -41,9 +59,6 @@ Bugs fixed:
|
|
41
59
|
* ruby24.y: "x = raise y rescue nil": bind rescue tighter than =. (whitequark)
|
42
60
|
* Builders::Default: "begin; else; 1; end": fix a crash. (whitequark)
|
43
61
|
|
44
|
-
v2.3.1.4 (2016-09-19)
|
45
|
-
---------------------
|
46
|
-
|
47
62
|
v2.3.1.3 (2016-09-17)
|
48
63
|
---------------------
|
49
64
|
|
@@ -116,9 +131,6 @@ v2.3.0.5 (2016-02-12)
|
|
116
131
|
Bugs fixed:
|
117
132
|
* lexer.rl: "%Q{\あ}": fix encoding of UTF-8 noop escapes. (whitequark)
|
118
133
|
|
119
|
-
v2.3.0.4 (2016-02-09)
|
120
|
-
---------------------
|
121
|
-
|
122
134
|
v2.3.0.3 (2016-02-06)
|
123
135
|
---------------------
|
124
136
|
|
@@ -132,9 +144,6 @@ Bugs fixed:
|
|
132
144
|
* Add :csend to Parser::Meta::NODE_TYPES (Markus Schirp)
|
133
145
|
* lexer/dedenter: "\<\<x\n y\\n z\nx": don't dedent after escaped newline. (whitequark)
|
134
146
|
|
135
|
-
v2.4.0.0 (2016-01-16)
|
136
|
-
---------------------
|
137
|
-
|
138
147
|
v2.3.0.1 (2016-01-14)
|
139
148
|
---------------------
|
140
149
|
|
@@ -264,9 +273,6 @@ v2.2.2.1 (2015-04-18)
|
|
264
273
|
Bugs fixed:
|
265
274
|
* builders/default: don't falsely diagnose multiline regexps (fixes #190). (whitequark)
|
266
275
|
|
267
|
-
v2.2.2.0 (2015-04-15)
|
268
|
-
---------------------
|
269
|
-
|
270
276
|
v2.2.0.4 (2015-04-15)
|
271
277
|
---------------------
|
272
278
|
|
@@ -274,12 +280,6 @@ Features implemented:
|
|
274
280
|
* Add Parser::Source::Map#node. (whitequark)
|
275
281
|
* Add Parser::Source::Comment.associate_locations. (kubicle)
|
276
282
|
|
277
|
-
v2.2.0.3 (2015-02-13)
|
278
|
-
---------------------
|
279
|
-
|
280
|
-
v2.2.0.2 (2015-01-09)
|
281
|
-
---------------------
|
282
|
-
|
283
283
|
v2.2.0.1 (2014-12-27)
|
284
284
|
---------------------
|
285
285
|
|
@@ -471,9 +471,6 @@ Bugs fixed:
|
|
471
471
|
* lexer.rl: "->*{}": tLAMBEG at expr_beg (fixes #103). (Peter Zotov)
|
472
472
|
* Source::Rewriter: apply actions in the insertion order. (Josh Cheek)
|
473
473
|
|
474
|
-
v2.0.0.pre6 (2013-08-02)
|
475
|
-
------------------------
|
476
|
-
|
477
474
|
v2.0.0.pre5 (2013-07-31)
|
478
475
|
------------------------
|
479
476
|
|
@@ -559,9 +556,6 @@ Features implemented:
|
|
559
556
|
Bugs fixed:
|
560
557
|
* Don't treat byte order mark as an identifier (closes #91). (Peter Zotov)
|
561
558
|
|
562
|
-
v2.0.0.pre1 (2013-07-04)
|
563
|
-
------------------------
|
564
|
-
|
565
559
|
v2.0.0.beta10 (2013-07-02)
|
566
560
|
--------------------------
|
567
561
|
|
@@ -767,9 +761,6 @@ Bugs fixed:
|
|
767
761
|
* ruby18.y, ruby19.y: BEGIN{} does not introduce a scope. (Peter Zotov)
|
768
762
|
* lexer.rl: improve whitespace handling. (Peter Zotov)
|
769
763
|
|
770
|
-
v0.9.1 (2013-04-15)
|
771
|
-
-------------------
|
772
|
-
|
773
764
|
v0.9.0 (2013-04-15)
|
774
765
|
-------------------
|
775
766
|
|
data/Rakefile
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rake/testtask'
|
5
5
|
require 'rake/clean'
|
6
|
+
require 'date'
|
6
7
|
|
7
8
|
task :default => [:test]
|
8
9
|
|
@@ -27,17 +28,20 @@ GENERATED_FILES = %w(lib/parser/lexer.rb
|
|
27
28
|
lib/parser/ruby22.rb
|
28
29
|
lib/parser/ruby23.rb
|
29
30
|
lib/parser/ruby24.rb
|
31
|
+
lib/parser/ruby25.rb
|
30
32
|
lib/parser/macruby.rb
|
31
33
|
lib/parser/rubymotion.rb)
|
32
34
|
|
33
35
|
CLEAN.include(GENERATED_FILES)
|
34
36
|
|
37
|
+
ENCODING_COMMENT = "# -*- encoding:utf-8; warn-indent:false; frozen_string_literal: true -*-\n"
|
38
|
+
|
35
39
|
desc 'Generate the Ragel lexer and Racc parser.'
|
36
40
|
task :generate => GENERATED_FILES do
|
37
41
|
Rake::Task[:ragel_check].invoke
|
38
42
|
GENERATED_FILES.each do |filename|
|
39
43
|
content = File.read(filename)
|
40
|
-
content =
|
44
|
+
content = ENCODING_COMMENT + content unless content.start_with?(ENCODING_COMMENT)
|
41
45
|
|
42
46
|
File.open(filename, 'w') do |io|
|
43
47
|
io.write content
|
@@ -98,7 +102,7 @@ task :changelog do
|
|
98
102
|
date = Date.parse(date)
|
99
103
|
|
100
104
|
current_version = "#{$1} (#{date})" if version =~ /(v[\d\w.]+)/
|
101
|
-
current_version = "
|
105
|
+
current_version = "Not released (#{date})" \
|
102
106
|
if version =~ /(^| |\/)#{Regexp.escape branch}$/
|
103
107
|
|
104
108
|
next if current_version.nil?
|
@@ -121,6 +125,7 @@ task :changelog do
|
|
121
125
|
io.puts
|
122
126
|
|
123
127
|
changelog.each do |version, commits|
|
128
|
+
next if commits.empty?
|
124
129
|
io.puts version
|
125
130
|
io.puts '-' * version.length
|
126
131
|
io.puts
|
data/doc/AST_FORMAT.md
CHANGED
@@ -626,15 +626,6 @@ Format:
|
|
626
626
|
"@a += 1"
|
627
627
|
~~~
|
628
628
|
|
629
|
-
Ruby_parser output for reference:
|
630
|
-
~~~
|
631
|
-
"a += 1"
|
632
|
-
s(:lasgn, :a, s(:call, s(:lvar, :a), :+, s(:int, 1)))
|
633
|
-
|
634
|
-
"@a += 1"
|
635
|
-
s(:iasgn, :@a, s(:call, s(:ivar, :@a), :+, s(:int, 1)))
|
636
|
-
~~~
|
637
|
-
|
638
629
|
#### Method binary operator-assignment
|
639
630
|
|
640
631
|
Format:
|
@@ -655,15 +646,6 @@ Format:
|
|
655
646
|
~~~~~~~~~~~~~ expression (op-asgn)
|
656
647
|
~~~
|
657
648
|
|
658
|
-
Ruby_parser output for reference:
|
659
|
-
~~~
|
660
|
-
"@a.b += 1"
|
661
|
-
s(:op_asgn2, s(:ivar, :@a), :b=, :+, s(:int, 1))
|
662
|
-
|
663
|
-
"@a[0, 1] += 1"
|
664
|
-
s(:op_asgn1, s(:ivar, :@a), s(:arglist, s(:int, 0), s(:int, 1)), :+, s(:int, 1))
|
665
|
-
~~~
|
666
|
-
|
667
649
|
### Logical operator-assignment
|
668
650
|
|
669
651
|
Logical operator-assignment features the same "incomplete assignments" and "incomplete calls" as [multiple assignment](#assignment-1).
|
@@ -684,15 +666,6 @@ Format:
|
|
684
666
|
~~~~~~~ expression
|
685
667
|
~~~
|
686
668
|
|
687
|
-
Ruby_parser output for reference:
|
688
|
-
~~~
|
689
|
-
"@a ||= 1"
|
690
|
-
s(:op_asgn_or, s(:ivar, :@a), s(:ivasgn, :@a, s(:int, 1)))
|
691
|
-
|
692
|
-
"a &&= 1"
|
693
|
-
s(:op_asgn_and, s(:lvar, :a), s(:lvasgn, :a, s(:int, 1)))
|
694
|
-
~~~
|
695
|
-
|
696
669
|
#### Method logical operator-assignment
|
697
670
|
|
698
671
|
Format:
|
@@ -721,16 +694,6 @@ Format:
|
|
721
694
|
|
722
695
|
~~~
|
723
696
|
|
724
|
-
Ruby_parser output for reference:
|
725
|
-
~~~
|
726
|
-
"@foo.bar &&= 1"
|
727
|
-
s(:op_asgn2, s(:ivar, :@foo), :bar=, :"&&", s(:int, 1))
|
728
|
-
|
729
|
-
"@foo[0] ||= 1"
|
730
|
-
s(:op_asgn1, s(:ivar, :@foo), s(:arglist, s(:int, 0)), :"||", s(:int, 1))
|
731
|
-
|
732
|
-
~~~
|
733
|
-
|
734
697
|
## Class and module definition
|
735
698
|
|
736
699
|
### Module
|
@@ -1135,6 +1098,7 @@ Format:
|
|
1135
1098
|
### To superclass
|
1136
1099
|
|
1137
1100
|
Format of super with arguments:
|
1101
|
+
|
1138
1102
|
~~~
|
1139
1103
|
(super (lvar :a))
|
1140
1104
|
"super a"
|
@@ -1150,6 +1114,7 @@ Format of super with arguments:
|
|
1150
1114
|
~~~
|
1151
1115
|
|
1152
1116
|
Format of super without arguments (**z**ero-arity):
|
1117
|
+
|
1153
1118
|
~~~
|
1154
1119
|
(zsuper)
|
1155
1120
|
"super"
|
data/lib/parser/all.rb
CHANGED
@@ -120,11 +120,18 @@ module Parser
|
|
120
120
|
end
|
121
121
|
private :numeric
|
122
122
|
|
123
|
-
def
|
123
|
+
def unary_num(unary_t, numeric)
|
124
124
|
value, = *numeric
|
125
|
-
operator_loc = loc(
|
125
|
+
operator_loc = loc(unary_t)
|
126
126
|
|
127
|
-
|
127
|
+
case value(unary_t)
|
128
|
+
when '+'
|
129
|
+
value = +value
|
130
|
+
when '-'
|
131
|
+
value = -value
|
132
|
+
end
|
133
|
+
|
134
|
+
numeric.updated(nil, [ value ],
|
128
135
|
:location =>
|
129
136
|
Source::Map::Operator.new(
|
130
137
|
operator_loc,
|
@@ -878,7 +885,7 @@ module Parser
|
|
878
885
|
|
879
886
|
def not_op(not_t, begin_t=nil, receiver=nil, end_t=nil)
|
880
887
|
if @parser.version == 18
|
881
|
-
n(:not, [ receiver ],
|
888
|
+
n(:not, [ check_condition(receiver) ],
|
882
889
|
unary_op_map(not_t, receiver))
|
883
890
|
else
|
884
891
|
if receiver.nil?
|
@@ -888,7 +895,7 @@ module Parser
|
|
888
895
|
nil_node, :'!'
|
889
896
|
], send_unary_op_map(not_t, nil_node))
|
890
897
|
else
|
891
|
-
n(:send, [ receiver, :'!' ],
|
898
|
+
n(:send, [ check_condition(receiver), :'!' ],
|
892
899
|
send_map(nil, nil, not_t, begin_t, [receiver], end_t))
|
893
900
|
end
|
894
901
|
end
|
@@ -1097,6 +1104,8 @@ module Parser
|
|
1097
1104
|
when :masgn
|
1098
1105
|
if @parser.version <= 23
|
1099
1106
|
diagnostic :error, :masgn_as_condition, nil, cond.loc.expression
|
1107
|
+
else
|
1108
|
+
cond
|
1100
1109
|
end
|
1101
1110
|
|
1102
1111
|
when :begin
|
@@ -1271,6 +1280,10 @@ module Parser
|
|
1271
1280
|
if begin_t.nil? || end_t.nil?
|
1272
1281
|
if parts.any?
|
1273
1282
|
expr_l = join_exprs(parts.first, parts.last)
|
1283
|
+
elsif !begin_t.nil?
|
1284
|
+
expr_l = loc(begin_t)
|
1285
|
+
elsif !end_t.nil?
|
1286
|
+
expr_l = loc(end_t)
|
1274
1287
|
end
|
1275
1288
|
else
|
1276
1289
|
expr_l = loc(begin_t).join(loc(end_t))
|
data/lib/parser/current.rb
CHANGED
@@ -37,7 +37,7 @@ module Parser
|
|
37
37
|
CurrentRuby = Ruby20
|
38
38
|
|
39
39
|
when /^2\.1\./
|
40
|
-
current_version = '2.1.
|
40
|
+
current_version = '2.1.10'
|
41
41
|
if RUBY_VERSION != current_version
|
42
42
|
warn_syntax_deviation 'parser/ruby21', current_version
|
43
43
|
end
|
@@ -46,7 +46,7 @@ module Parser
|
|
46
46
|
CurrentRuby = Ruby21
|
47
47
|
|
48
48
|
when /^2\.2\./
|
49
|
-
current_version = '2.2.
|
49
|
+
current_version = '2.2.8'
|
50
50
|
if RUBY_VERSION != current_version
|
51
51
|
warn_syntax_deviation 'parser/ruby22', current_version
|
52
52
|
end
|
@@ -55,7 +55,7 @@ module Parser
|
|
55
55
|
CurrentRuby = Ruby22
|
56
56
|
|
57
57
|
when /^2\.3\./
|
58
|
-
current_version = '2.3.
|
58
|
+
current_version = '2.3.4'
|
59
59
|
if RUBY_VERSION != current_version
|
60
60
|
warn_syntax_deviation 'parser/ruby23', current_version
|
61
61
|
end
|
@@ -72,6 +72,15 @@ module Parser
|
|
72
72
|
require 'parser/ruby24'
|
73
73
|
CurrentRuby = Ruby24
|
74
74
|
|
75
|
+
when /^2\.5\./
|
76
|
+
current_version = '2.5.0'
|
77
|
+
if RUBY_VERSION != current_version
|
78
|
+
warn_syntax_deviation 'parser/ruby25', current_version
|
79
|
+
end
|
80
|
+
|
81
|
+
require 'parser/ruby25'
|
82
|
+
CurrentRuby = Ruby25
|
83
|
+
|
75
84
|
else # :nocov:
|
76
85
|
# Keep this in sync with released Ruby.
|
77
86
|
warn_syntax_deviation 'parser/ruby24', '2.4.x'
|
data/lib/parser/lexer.rl
CHANGED
@@ -1621,16 +1621,11 @@ class Parser::Lexer
|
|
1621
1621
|
# explodes.
|
1622
1622
|
#
|
1623
1623
|
expr_beg := |*
|
1624
|
-
#
|
1625
|
-
|
1626
|
-
# -5 to [tUMINUS_NUM] [tINTEGER, 5]
|
1627
|
-
[+\-][0-9]
|
1624
|
+
# +5, -5, - 5
|
1625
|
+
[+\-] w_any* [0-9]
|
1628
1626
|
=> {
|
1629
|
-
|
1630
|
-
|
1631
|
-
emit(:tUMINUS_NUM, '-'.freeze, @ts, @ts + 1)
|
1632
|
-
fnext expr_end; fbreak;
|
1633
|
-
end
|
1627
|
+
emit(:tUNARY_NUM, tok(@ts, @ts + 1), @ts, @ts + 1)
|
1628
|
+
fhold; fnext expr_end; fbreak;
|
1634
1629
|
};
|
1635
1630
|
|
1636
1631
|
# splat *a
|
data/lib/parser/lexer/literal.rb
CHANGED
data/lib/parser/macruby.y
CHANGED
@@ -7,7 +7,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
7
7
|
kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__
|
8
8
|
k__FILE__ k__ENCODING__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
|
9
9
|
tLABEL tCVAR tNTH_REF tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT
|
10
|
-
tUPLUS tUMINUS
|
10
|
+
tUPLUS tUMINUS tUNARY_NUM tPOW tCMP tEQ tEQQ tNEQ
|
11
11
|
tGEQ tLEQ tANDOP tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF
|
12
12
|
tASET tLSHFT tRSHFT tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN
|
13
13
|
tLPAREN2 tRPAREN tLPAREN_ARG tLBRACK tLBRACK2 tRBRACK tLBRACE
|
@@ -21,7 +21,7 @@ token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS
|
|
21
21
|
prechigh
|
22
22
|
right tBANG tTILDE tUPLUS
|
23
23
|
right tPOW
|
24
|
-
right
|
24
|
+
right tUNARY_NUM tUMINUS
|
25
25
|
left tSTAR2 tDIVIDE tPERCENT
|
26
26
|
left tPLUS tMINUS
|
27
27
|
left tLSHFT tRSHFT
|
@@ -670,14 +670,14 @@ rule
|
|
670
670
|
{
|
671
671
|
result = @builder.binary_op(val[0], val[1], val[2])
|
672
672
|
}
|
673
|
-
|
|
673
|
+
| tUNARY_NUM tINTEGER tPOW arg
|
674
674
|
{
|
675
675
|
result = @builder.unary_op(val[0],
|
676
676
|
@builder.binary_op(
|
677
677
|
@builder.integer(val[1]),
|
678
678
|
val[2], val[3]))
|
679
679
|
}
|
680
|
-
|
|
680
|
+
| tUNARY_NUM tFLOAT tPOW arg
|
681
681
|
{
|
682
682
|
result = @builder.unary_op(val[0],
|
683
683
|
@builder.binary_op(
|
@@ -1786,15 +1786,25 @@ regexp_contents: # nothing
|
|
1786
1786
|
{
|
1787
1787
|
result = @builder.float(val[0])
|
1788
1788
|
}
|
1789
|
-
|
|
1789
|
+
| tUNARY_NUM tINTEGER =tLOWEST
|
1790
1790
|
{
|
1791
|
-
|
1792
|
-
|
1791
|
+
num = @builder.integer(val[1])
|
1792
|
+
if @builder.respond_to? :negate
|
1793
|
+
# AST builder interface compatibility
|
1794
|
+
result = @builder.negate(val[0], num)
|
1795
|
+
else
|
1796
|
+
result = @builder.unary_num(val[0], num)
|
1797
|
+
end
|
1793
1798
|
}
|
1794
|
-
|
|
1799
|
+
| tUNARY_NUM tFLOAT =tLOWEST
|
1795
1800
|
{
|
1796
|
-
|
1797
|
-
|
1801
|
+
num = @builder.float(val[1])
|
1802
|
+
if @builder.respond_to? :negate
|
1803
|
+
# AST builder interface compatibility
|
1804
|
+
result = @builder.negate(val[0], num)
|
1805
|
+
else
|
1806
|
+
result = @builder.unary_num(val[0], num)
|
1807
|
+
end
|
1798
1808
|
}
|
1799
1809
|
|
1800
1810
|
variable: tIDENTIFIER
|