ruby_parser 3.12.0 → 3.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/.autotest +18 -29
- data/History.rdoc +283 -0
- data/Manifest.txt +12 -4
- data/README.rdoc +4 -3
- data/Rakefile +189 -51
- data/bin/ruby_parse +3 -1
- data/bin/ruby_parse_extract_error +19 -36
- data/compare/normalize.rb +76 -4
- data/debugging.md +190 -0
- data/gauntlet.md +106 -0
- data/lib/rp_extensions.rb +14 -42
- data/lib/rp_stringscanner.rb +20 -51
- data/lib/ruby20_parser.rb +4659 -4218
- data/lib/ruby20_parser.y +953 -602
- data/lib/ruby21_parser.rb +4723 -4308
- data/lib/ruby21_parser.y +956 -605
- data/lib/ruby22_parser.rb +4762 -4337
- data/lib/ruby22_parser.y +960 -612
- data/lib/ruby23_parser.rb +4761 -4342
- data/lib/ruby23_parser.y +961 -613
- data/lib/ruby24_parser.rb +4791 -4341
- data/lib/ruby24_parser.y +968 -612
- data/lib/ruby25_parser.rb +4791 -4341
- data/lib/ruby25_parser.y +968 -612
- data/lib/ruby26_parser.rb +7287 -0
- data/lib/ruby26_parser.y +2749 -0
- data/lib/ruby27_parser.rb +8517 -0
- data/lib/ruby27_parser.y +3346 -0
- data/lib/ruby30_parser.rb +8751 -0
- data/lib/ruby30_parser.y +3472 -0
- data/lib/ruby3_parser.yy +3476 -0
- data/lib/ruby_lexer.rb +611 -826
- data/lib/ruby_lexer.rex +48 -40
- data/lib/ruby_lexer.rex.rb +122 -46
- data/lib/ruby_lexer_strings.rb +638 -0
- data/lib/ruby_parser.rb +38 -34
- data/lib/ruby_parser.yy +1710 -704
- data/lib/ruby_parser_extras.rb +987 -553
- data/test/test_ruby_lexer.rb +1718 -1539
- data/test/test_ruby_parser.rb +3957 -2164
- data/test/test_ruby_parser_extras.rb +39 -4
- data/tools/munge.rb +250 -0
- data/tools/ripper.rb +44 -0
- data.tar.gz.sig +0 -0
- metadata +68 -47
- metadata.gz.sig +0 -0
- data/lib/ruby18_parser.rb +0 -5793
- data/lib/ruby18_parser.y +0 -1908
- data/lib/ruby19_parser.rb +0 -6185
- data/lib/ruby19_parser.y +0 -2116
data/lib/ruby_lexer.rex
CHANGED
@@ -4,11 +4,16 @@
|
|
4
4
|
|
5
5
|
class RubyLexer
|
6
6
|
|
7
|
+
option
|
8
|
+
|
9
|
+
lineno
|
10
|
+
column
|
11
|
+
|
7
12
|
macro
|
8
13
|
|
9
|
-
|
14
|
+
IDENT_CHAR /[a-zA-Z0-9_[:^ascii:]]/
|
10
15
|
|
11
|
-
ESC /\\((?>[0-7]{1,3}|x
|
16
|
+
ESC /\\((?>[0-7]{1,3}|x\h{1,2}|M-[^\\]|(C-|c)[^\\]|u\h{1,4}|u\{\h+(?:\s+\h+)*\}|[^0-7xMCc]))/
|
12
17
|
SIMPLE_STRING /((#{ESC}|\#(#{ESC}|[^\{\#\@\$\"\\])|[^\"\\\#])*)/o
|
13
18
|
SSTRING /((\\.|[^\'])*)/
|
14
19
|
|
@@ -25,11 +30,12 @@ macro
|
|
25
30
|
|
26
31
|
start
|
27
32
|
|
28
|
-
|
33
|
+
maybe_pop_stack
|
34
|
+
return process_string_or_heredoc if lex_strterm
|
29
35
|
|
30
|
-
self.
|
36
|
+
self.cmd_state = self.command_start
|
31
37
|
self.command_start = false
|
32
|
-
self.space_seen = false
|
38
|
+
self.space_seen = false # TODO: rename token_seen?
|
33
39
|
self.last_state = lex_state
|
34
40
|
|
35
41
|
rule
|
@@ -37,24 +43,24 @@ rule
|
|
37
43
|
# [:state] pattern [actions]
|
38
44
|
|
39
45
|
# \s - \n + \v
|
40
|
-
/[\ \t\r\f\v]
|
46
|
+
/[\ \t\r\f\v]+/ { self.space_seen = true; next }
|
41
47
|
|
42
48
|
/\n|\#/ process_newline_or_comment
|
43
49
|
|
44
|
-
/[\]\)\}]/
|
50
|
+
/[\]\)\}]/ process_brace_close
|
45
51
|
|
46
52
|
: /\!/
|
47
|
-
|
|
53
|
+
| is_after_operator? /\!\@/ { result EXPR_ARG, TOKENS[text], text }
|
48
54
|
| /\![=~]?/ { result :arg_state, TOKENS[text], text }
|
49
55
|
|
50
56
|
: /\./
|
51
|
-
| /\.\.\.?/
|
57
|
+
| /\.\.\.?/ process_dots
|
52
58
|
| /\.\d/ { rb_compile_error "no .<digit> floating literal anymore put 0 before dot" }
|
53
|
-
| /\./ { result
|
59
|
+
| /\./ { self.lex_state = EXPR_BEG; result EXPR_DOT, :tDOT, "." }
|
54
60
|
|
55
61
|
/\(/ process_paren
|
56
62
|
|
57
|
-
/\,/ { result
|
63
|
+
/\,/ { result EXPR_PAR, TOKENS[text], text }
|
58
64
|
|
59
65
|
: /=/
|
60
66
|
| /\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/ { result arg_state, TOKENS[text], text }
|
@@ -62,8 +68,8 @@ rule
|
|
62
68
|
| /\=(?=begin\b)/ { result arg_state, TOKENS[text], text }
|
63
69
|
|
64
70
|
ruby22_label? /\"#{SIMPLE_STRING}\":/o process_label
|
65
|
-
/\"(#{SIMPLE_STRING})\"/o
|
66
|
-
/\"/ { string STR_DQUOTE; result nil, :tSTRING_BEG, text }
|
71
|
+
/\"(#{SIMPLE_STRING})\"/o process_simple_string
|
72
|
+
/\"/ { string STR_DQUOTE, '"'; result nil, :tSTRING_BEG, text }
|
67
73
|
|
68
74
|
/\@\@?\d/ { rb_compile_error "`#{text}` is not allowed as a variable name" }
|
69
75
|
/\@\@?#{IDENT_CHAR}+/o process_ivar
|
@@ -75,7 +81,7 @@ ruby22_label? /\"#{SIMPLE_STRING}\":/o process_label
|
|
75
81
|
| /\:\:/ process_colon2
|
76
82
|
| /\:/ process_colon1
|
77
83
|
|
78
|
-
/->/ { result
|
84
|
+
/->/ { result EXPR_ENDFN, :tLAMBDA, text }
|
79
85
|
|
80
86
|
/[+-]/ process_plus_minus
|
81
87
|
|
@@ -94,59 +100,61 @@ ruby22_label? /\"#{SIMPLE_STRING}\":/o process_label
|
|
94
100
|
/\[/ process_square_bracket
|
95
101
|
|
96
102
|
was_label? /\'#{SSTRING}\':?/o process_label_or_string
|
103
|
+
/\'/ { string STR_SQUOTE, "'"; result nil, :tSTRING_BEG, text }
|
97
104
|
|
98
105
|
: /\|/
|
99
|
-
| /\|\|\=/ { result
|
100
|
-
| /\|\|/ { result
|
101
|
-
| /\|\=/ { result
|
102
|
-
| /\|/ { result
|
106
|
+
| /\|\|\=/ { result EXPR_BEG, :tOP_ASGN, "||" }
|
107
|
+
| /\|\|/ { result EXPR_BEG, :tOROP, "||" }
|
108
|
+
| /\|\=/ { result EXPR_BEG, :tOP_ASGN, "|" }
|
109
|
+
| /\|/ { state = is_after_operator? ? EXPR_ARG : EXPR_PAR; result state, :tPIPE, "|" }
|
103
110
|
|
104
|
-
/\{/
|
111
|
+
/\{/ process_brace_open
|
105
112
|
|
106
113
|
: /\*/
|
107
|
-
| /\*\*=/ { result
|
108
|
-
| /\*\*/ { result
|
109
|
-
| /\*\=/ { result
|
110
|
-
| /\*/ { result
|
114
|
+
| /\*\*=/ { result EXPR_BEG, :tOP_ASGN, "**" }
|
115
|
+
| /\*\*/ { result :arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**" }
|
116
|
+
| /\*\=/ { result EXPR_BEG, :tOP_ASGN, "*" }
|
117
|
+
| /\*/ { result :arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*" }
|
111
118
|
|
119
|
+
# TODO: fix result+process_lchevron to set command_start = true
|
112
120
|
: /</
|
113
121
|
| /\<\=\>/ { result :arg_state, :tCMP, "<=>" }
|
114
122
|
| /\<\=/ { result :arg_state, :tLEQ, "<=" }
|
115
|
-
| /\<\<\=/ { result
|
123
|
+
| /\<\<\=/ { result EXPR_BEG, :tOP_ASGN, "<<" }
|
116
124
|
| /\<\</ process_lchevron
|
117
125
|
| /\</ { result :arg_state, :tLT, "<" }
|
118
126
|
|
119
127
|
: />/
|
120
128
|
| /\>\=/ { result :arg_state, :tGEQ, ">=" }
|
121
|
-
| /\>\>=/ { result
|
129
|
+
| /\>\>=/ { result EXPR_BEG, :tOP_ASGN, ">>" }
|
122
130
|
| /\>\>/ { result :arg_state, :tRSHFT, ">>" }
|
123
131
|
| /\>/ { result :arg_state, :tGT, ">" }
|
124
132
|
|
125
133
|
: /\`/
|
126
|
-
| expr_fname? /\`/ { result
|
127
|
-
| expr_dot? /\`/ { result((
|
128
|
-
| /\`/ { string STR_XQUOTE, '`'; result
|
134
|
+
| expr_fname? /\`/ { result EXPR_END, :tBACK_REF2, "`" }
|
135
|
+
| expr_dot? /\`/ { result((cmd_state ? EXPR_CMDARG : EXPR_ARG), :tBACK_REF2, "`") }
|
136
|
+
| /\`/ { string STR_XQUOTE, '`'; result nil, :tXSTRING_BEG, "`" }
|
129
137
|
|
130
138
|
/\?/ process_questionmark
|
131
139
|
|
132
140
|
: /&/
|
133
|
-
| /\&\&\=/ { result
|
134
|
-
| /\&\&/ { result
|
135
|
-
| /\&\=/ { result
|
136
|
-
| /\&\./ { result
|
141
|
+
| /\&\&\=/ { result EXPR_BEG, :tOP_ASGN, "&&" }
|
142
|
+
| /\&\&/ { result EXPR_BEG, :tANDOP, "&&" }
|
143
|
+
| /\&\=/ { result EXPR_BEG, :tOP_ASGN, "&" }
|
144
|
+
| /\&\./ { result EXPR_DOT, :tLONELY, "&." }
|
137
145
|
| /\&/ process_amper
|
138
146
|
|
139
147
|
/\// process_slash
|
140
148
|
|
141
149
|
: /\^/
|
142
|
-
| /\^=/ { result
|
143
|
-
| /\^/ { result
|
150
|
+
| /\^=/ { result EXPR_BEG, :tOP_ASGN, "^" }
|
151
|
+
| /\^/ { result :arg_state, :tCARET, "^" }
|
144
152
|
|
145
|
-
/\;/ { self.command_start = true; result
|
153
|
+
/\;/ { self.command_start = true; result EXPR_BEG, :tSEMI, ";" }
|
146
154
|
|
147
155
|
: /~/
|
148
|
-
|
|
149
|
-
| /\~/ { result
|
156
|
+
| is_after_operator? /\~@/ { result :arg_state, :tTILDE, "~" }
|
157
|
+
| /\~/ { result :arg_state, :tTILDE, "~" }
|
150
158
|
|
151
159
|
: /\\/
|
152
160
|
| /\\\r?\n/ { self.lineno += 1; self.space_seen = true; next }
|
@@ -163,12 +171,12 @@ was_label? /\'#{SSTRING}\':?/o process_label_or_string
|
|
163
171
|
| in_fname? /\$([1-9]\d*)/ process_gvar
|
164
172
|
| /\$([1-9]\d*)/ process_nthref
|
165
173
|
| /\$0/ process_gvar
|
166
|
-
|
|
167
|
-
| /\$\
|
174
|
+
| /\$#{IDENT_CHAR}+/ process_gvar
|
175
|
+
| /\$\W/ process_gvar_oddity
|
168
176
|
|
169
177
|
/\_/ process_underscore
|
170
178
|
|
171
|
-
/#{
|
179
|
+
/#{IDENT_CHAR}+/o process_token
|
172
180
|
|
173
181
|
/\004|\032|\000|\Z/ { [RubyLexer::EOF, RubyLexer::EOF] }
|
174
182
|
|
data/lib/ruby_lexer.rex.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# encoding: UTF-8
|
2
3
|
#--
|
3
4
|
# This file is automatically generated. Do not modify it.
|
4
|
-
# Generated by: oedipus_lex version 2.
|
5
|
+
# Generated by: oedipus_lex version 2.6.0.
|
5
6
|
# Source: lib/ruby_lexer.rex
|
6
7
|
#++
|
7
8
|
|
8
9
|
#
|
9
10
|
# lexical scanner definition for ruby
|
10
11
|
|
12
|
+
|
13
|
+
##
|
14
|
+
# The generated lexer RubyLexer
|
15
|
+
|
11
16
|
class RubyLexer
|
12
17
|
require 'strscan'
|
13
18
|
|
14
|
-
|
15
|
-
|
19
|
+
# :stopdoc:
|
20
|
+
IDENT_CHAR = /[a-zA-Z0-9_[:^ascii:]]/
|
21
|
+
ESC = /\\((?>[0-7]{1,3}|x\h{1,2}|M-[^\\]|(C-|c)[^\\]|u\h{1,4}|u\{\h+(?:\s+\h+)*\}|[^0-7xMCc]))/
|
16
22
|
SIMPLE_STRING = /((#{ESC}|\#(#{ESC}|[^\{\#\@\$\"\\])|[^\"\\\#])*)/o
|
17
23
|
SSTRING = /((\\.|[^\'])*)/
|
18
24
|
INT_DEC = /[+]?(?:(?:[1-9][\d_]*|0)(?!\.\d)(ri|r|i)?\b|0d[0-9_]+)(ri|r|i)?/i
|
@@ -24,37 +30,90 @@ class RubyLexer
|
|
24
30
|
NUM_BAD = /[+]?0[xbd]\b/i
|
25
31
|
INT_OCT_BAD = /[+]?0o?[0-7_]*[89]/i
|
26
32
|
FLOAT_BAD = /[+]?\d[\d_]*_(e|\.)/i
|
27
|
-
|
33
|
+
# :startdoc:
|
34
|
+
# :stopdoc:
|
28
35
|
class LexerError < StandardError ; end
|
29
36
|
class ScanError < LexerError ; end
|
37
|
+
# :startdoc:
|
38
|
+
|
39
|
+
##
|
40
|
+
# The current line number.
|
41
|
+
|
42
|
+
attr_accessor :lineno
|
43
|
+
##
|
44
|
+
# The file name / path
|
30
45
|
|
31
46
|
attr_accessor :filename
|
47
|
+
|
48
|
+
##
|
49
|
+
# The StringScanner for this lexer.
|
50
|
+
|
32
51
|
attr_accessor :ss
|
52
|
+
|
53
|
+
##
|
54
|
+
# The current lexical state.
|
55
|
+
|
33
56
|
attr_accessor :state
|
34
57
|
|
35
58
|
alias :match :ss
|
36
59
|
|
60
|
+
##
|
61
|
+
# The match groups for the current scan.
|
62
|
+
|
37
63
|
def matches
|
38
64
|
m = (1..9).map { |i| ss[i] }
|
39
65
|
m.pop until m[-1] or m.empty?
|
40
66
|
m
|
41
67
|
end
|
42
68
|
|
69
|
+
##
|
70
|
+
# Yields on the current action.
|
71
|
+
|
43
72
|
def action
|
44
73
|
yield
|
45
74
|
end
|
46
75
|
|
76
|
+
##
|
77
|
+
# The previous position. Only available if the :column option is on.
|
78
|
+
|
79
|
+
attr_accessor :old_pos
|
80
|
+
|
81
|
+
##
|
82
|
+
# The position of the start of the current line. Only available if the
|
83
|
+
# :column option is on.
|
84
|
+
|
85
|
+
attr_accessor :start_of_current_line_pos
|
86
|
+
|
87
|
+
##
|
88
|
+
# The current column, starting at 0. Only available if the
|
89
|
+
# :column option is on.
|
90
|
+
def column
|
91
|
+
old_pos - start_of_current_line_pos
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
##
|
96
|
+
# The current scanner class. Must be overridden in subclasses.
|
97
|
+
|
47
98
|
def scanner_class
|
48
99
|
StringScanner
|
49
100
|
end unless instance_methods(false).map(&:to_s).include?("scanner_class")
|
50
101
|
|
102
|
+
##
|
103
|
+
# Parse the given string.
|
104
|
+
|
51
105
|
def parse str
|
52
106
|
self.ss = scanner_class.new str
|
107
|
+
self.lineno = 1
|
108
|
+
self.start_of_current_line_pos = 0
|
53
109
|
self.state ||= nil
|
54
110
|
|
55
111
|
do_parse
|
56
112
|
end
|
57
113
|
|
114
|
+
##
|
115
|
+
# Read in and parse the file at +path+.
|
116
|
+
|
58
117
|
def parse_file path
|
59
118
|
self.filename = path
|
60
119
|
open path do |f|
|
@@ -62,52 +121,67 @@ class RubyLexer
|
|
62
121
|
end
|
63
122
|
end
|
64
123
|
|
124
|
+
##
|
125
|
+
# The current location in the parse.
|
126
|
+
|
65
127
|
def location
|
66
128
|
[
|
67
129
|
(filename || "<input>"),
|
130
|
+
lineno,
|
131
|
+
column,
|
68
132
|
].compact.join(":")
|
69
133
|
end
|
70
134
|
|
135
|
+
##
|
136
|
+
# Lex the next token.
|
137
|
+
|
71
138
|
def next_token
|
72
|
-
|
73
|
-
|
139
|
+
maybe_pop_stack
|
140
|
+
return process_string_or_heredoc if lex_strterm
|
141
|
+
self.cmd_state = self.command_start
|
74
142
|
self.command_start = false
|
75
|
-
self.space_seen = false
|
143
|
+
self.space_seen = false # TODO: rename token_seen?
|
76
144
|
self.last_state = lex_state
|
77
145
|
|
78
146
|
token = nil
|
79
147
|
|
80
148
|
until ss.eos? or token do
|
149
|
+
if ss.check(/\n/) then
|
150
|
+
self.lineno += 1
|
151
|
+
# line starts 1 position after the newline
|
152
|
+
self.start_of_current_line_pos = ss.pos + 1
|
153
|
+
end
|
154
|
+
self.old_pos = ss.pos
|
81
155
|
token =
|
82
156
|
case state
|
83
157
|
when nil then
|
84
158
|
case
|
85
|
-
when ss.skip(/[\ \t\r\f\v]
|
159
|
+
when ss.skip(/[\ \t\r\f\v]+/) then
|
86
160
|
action { self.space_seen = true; next }
|
87
161
|
when text = ss.scan(/\n|\#/) then
|
88
162
|
process_newline_or_comment text
|
89
163
|
when text = ss.scan(/[\]\)\}]/) then
|
90
|
-
|
164
|
+
process_brace_close text
|
91
165
|
when ss.match?(/\!/) then
|
92
166
|
case
|
93
|
-
when
|
94
|
-
action { result
|
167
|
+
when is_after_operator? && (text = ss.scan(/\!\@/)) then
|
168
|
+
action { result EXPR_ARG, TOKENS[text], text }
|
95
169
|
when text = ss.scan(/\![=~]?/) then
|
96
170
|
action { result :arg_state, TOKENS[text], text }
|
97
171
|
end # group /\!/
|
98
172
|
when ss.match?(/\./) then
|
99
173
|
case
|
100
174
|
when text = ss.scan(/\.\.\.?/) then
|
101
|
-
|
175
|
+
process_dots text
|
102
176
|
when ss.skip(/\.\d/) then
|
103
177
|
action { rb_compile_error "no .<digit> floating literal anymore put 0 before dot" }
|
104
178
|
when ss.skip(/\./) then
|
105
|
-
action { result
|
179
|
+
action { self.lex_state = EXPR_BEG; result EXPR_DOT, :tDOT, "." }
|
106
180
|
end # group /\./
|
107
181
|
when text = ss.scan(/\(/) then
|
108
182
|
process_paren text
|
109
183
|
when text = ss.scan(/\,/) then
|
110
|
-
action { result
|
184
|
+
action { result EXPR_PAR, TOKENS[text], text }
|
111
185
|
when ss.match?(/=/) then
|
112
186
|
case
|
113
187
|
when text = ss.scan(/\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/) then
|
@@ -120,9 +194,9 @@ class RubyLexer
|
|
120
194
|
when ruby22_label? && (text = ss.scan(/\"#{SIMPLE_STRING}\":/o)) then
|
121
195
|
process_label text
|
122
196
|
when text = ss.scan(/\"(#{SIMPLE_STRING})\"/o) then
|
123
|
-
|
197
|
+
process_simple_string text
|
124
198
|
when text = ss.scan(/\"/) then
|
125
|
-
action { string STR_DQUOTE; result nil, :tSTRING_BEG, text }
|
199
|
+
action { string STR_DQUOTE, '"'; result nil, :tSTRING_BEG, text }
|
126
200
|
when text = ss.scan(/\@\@?\d/) then
|
127
201
|
action { rb_compile_error "`#{text}` is not allowed as a variable name" }
|
128
202
|
when text = ss.scan(/\@\@?#{IDENT_CHAR}+/o) then
|
@@ -140,8 +214,8 @@ class RubyLexer
|
|
140
214
|
when text = ss.scan(/\:/) then
|
141
215
|
process_colon1 text
|
142
216
|
end # group /:/
|
143
|
-
when ss.
|
144
|
-
action { result
|
217
|
+
when text = ss.scan(/->/) then
|
218
|
+
action { result EXPR_ENDFN, :tLAMBDA, text }
|
145
219
|
when text = ss.scan(/[+-]/) then
|
146
220
|
process_plus_minus text
|
147
221
|
when ss.match?(/[+\d]/) then
|
@@ -171,29 +245,31 @@ class RubyLexer
|
|
171
245
|
process_square_bracket text
|
172
246
|
when was_label? && (text = ss.scan(/\'#{SSTRING}\':?/o)) then
|
173
247
|
process_label_or_string text
|
248
|
+
when text = ss.scan(/\'/) then
|
249
|
+
action { string STR_SQUOTE, "'"; result nil, :tSTRING_BEG, text }
|
174
250
|
when ss.match?(/\|/) then
|
175
251
|
case
|
176
252
|
when ss.skip(/\|\|\=/) then
|
177
|
-
action { result
|
253
|
+
action { result EXPR_BEG, :tOP_ASGN, "||" }
|
178
254
|
when ss.skip(/\|\|/) then
|
179
|
-
action { result
|
255
|
+
action { result EXPR_BEG, :tOROP, "||" }
|
180
256
|
when ss.skip(/\|\=/) then
|
181
|
-
action { result
|
257
|
+
action { result EXPR_BEG, :tOP_ASGN, "|" }
|
182
258
|
when ss.skip(/\|/) then
|
183
|
-
action { result
|
259
|
+
action { state = is_after_operator? ? EXPR_ARG : EXPR_PAR; result state, :tPIPE, "|" }
|
184
260
|
end # group /\|/
|
185
261
|
when text = ss.scan(/\{/) then
|
186
|
-
|
262
|
+
process_brace_open text
|
187
263
|
when ss.match?(/\*/) then
|
188
264
|
case
|
189
265
|
when ss.skip(/\*\*=/) then
|
190
|
-
action { result
|
266
|
+
action { result EXPR_BEG, :tOP_ASGN, "**" }
|
191
267
|
when ss.skip(/\*\*/) then
|
192
|
-
action { result
|
268
|
+
action { result :arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**" }
|
193
269
|
when ss.skip(/\*\=/) then
|
194
|
-
action { result
|
270
|
+
action { result EXPR_BEG, :tOP_ASGN, "*" }
|
195
271
|
when ss.skip(/\*/) then
|
196
|
-
action { result
|
272
|
+
action { result :arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*" }
|
197
273
|
end # group /\*/
|
198
274
|
when ss.match?(/</) then
|
199
275
|
case
|
@@ -202,7 +278,7 @@ class RubyLexer
|
|
202
278
|
when ss.skip(/\<\=/) then
|
203
279
|
action { result :arg_state, :tLEQ, "<=" }
|
204
280
|
when ss.skip(/\<\<\=/) then
|
205
|
-
action { result
|
281
|
+
action { result EXPR_BEG, :tOP_ASGN, "<<" }
|
206
282
|
when text = ss.scan(/\<\</) then
|
207
283
|
process_lchevron text
|
208
284
|
when ss.skip(/\</) then
|
@@ -213,7 +289,7 @@ class RubyLexer
|
|
213
289
|
when ss.skip(/\>\=/) then
|
214
290
|
action { result :arg_state, :tGEQ, ">=" }
|
215
291
|
when ss.skip(/\>\>=/) then
|
216
|
-
action { result
|
292
|
+
action { result EXPR_BEG, :tOP_ASGN, ">>" }
|
217
293
|
when ss.skip(/\>\>/) then
|
218
294
|
action { result :arg_state, :tRSHFT, ">>" }
|
219
295
|
when ss.skip(/\>/) then
|
@@ -222,24 +298,24 @@ class RubyLexer
|
|
222
298
|
when ss.match?(/\`/) then
|
223
299
|
case
|
224
300
|
when expr_fname? && (ss.skip(/\`/)) then
|
225
|
-
action { result
|
301
|
+
action { result EXPR_END, :tBACK_REF2, "`" }
|
226
302
|
when expr_dot? && (ss.skip(/\`/)) then
|
227
|
-
action { result((
|
303
|
+
action { result((cmd_state ? EXPR_CMDARG : EXPR_ARG), :tBACK_REF2, "`") }
|
228
304
|
when ss.skip(/\`/) then
|
229
|
-
action { string STR_XQUOTE, '`'; result
|
305
|
+
action { string STR_XQUOTE, '`'; result nil, :tXSTRING_BEG, "`" }
|
230
306
|
end # group /\`/
|
231
307
|
when text = ss.scan(/\?/) then
|
232
308
|
process_questionmark text
|
233
309
|
when ss.match?(/&/) then
|
234
310
|
case
|
235
311
|
when ss.skip(/\&\&\=/) then
|
236
|
-
action { result
|
312
|
+
action { result EXPR_BEG, :tOP_ASGN, "&&" }
|
237
313
|
when ss.skip(/\&\&/) then
|
238
|
-
action { result
|
314
|
+
action { result EXPR_BEG, :tANDOP, "&&" }
|
239
315
|
when ss.skip(/\&\=/) then
|
240
|
-
action { result
|
316
|
+
action { result EXPR_BEG, :tOP_ASGN, "&" }
|
241
317
|
when ss.skip(/\&\./) then
|
242
|
-
action { result
|
318
|
+
action { result EXPR_DOT, :tLONELY, "&." }
|
243
319
|
when text = ss.scan(/\&/) then
|
244
320
|
process_amper text
|
245
321
|
end # group /&/
|
@@ -248,18 +324,18 @@ class RubyLexer
|
|
248
324
|
when ss.match?(/\^/) then
|
249
325
|
case
|
250
326
|
when ss.skip(/\^=/) then
|
251
|
-
action { result
|
327
|
+
action { result EXPR_BEG, :tOP_ASGN, "^" }
|
252
328
|
when ss.skip(/\^/) then
|
253
|
-
action { result
|
329
|
+
action { result :arg_state, :tCARET, "^" }
|
254
330
|
end # group /\^/
|
255
331
|
when ss.skip(/\;/) then
|
256
|
-
action { self.command_start = true; result
|
332
|
+
action { self.command_start = true; result EXPR_BEG, :tSEMI, ";" }
|
257
333
|
when ss.match?(/~/) then
|
258
334
|
case
|
259
|
-
when
|
260
|
-
action { result
|
335
|
+
when is_after_operator? && (ss.skip(/\~@/)) then
|
336
|
+
action { result :arg_state, :tTILDE, "~" }
|
261
337
|
when ss.skip(/\~/) then
|
262
|
-
action { result
|
338
|
+
action { result :arg_state, :tTILDE, "~" }
|
263
339
|
end # group /~/
|
264
340
|
when ss.match?(/\\/) then
|
265
341
|
case
|
@@ -288,14 +364,14 @@ class RubyLexer
|
|
288
364
|
process_nthref text
|
289
365
|
when text = ss.scan(/\$0/) then
|
290
366
|
process_gvar text
|
291
|
-
when text = ss.scan(
|
292
|
-
process_gvar_oddity text
|
293
|
-
when text = ss.scan(/\$\w+/) then
|
367
|
+
when text = ss.scan(/\$#{IDENT_CHAR}+/) then
|
294
368
|
process_gvar text
|
369
|
+
when text = ss.scan(/\$\W/) then
|
370
|
+
process_gvar_oddity text
|
295
371
|
end # group /\$/
|
296
372
|
when text = ss.scan(/\_/) then
|
297
373
|
process_underscore text
|
298
|
-
when text = ss.scan(/#{
|
374
|
+
when text = ss.scan(/#{IDENT_CHAR}+/o) then
|
299
375
|
process_token text
|
300
376
|
when ss.skip(/\004|\032|\000|\Z/) then
|
301
377
|
action { [RubyLexer::EOF, RubyLexer::EOF] }
|