ruby_parser 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ruby_lexer.rb CHANGED
@@ -132,6 +132,14 @@ class RubyLexer
132
132
  ss.eos?
133
133
  end
134
134
 
135
+ def expr_dot?
136
+ lex_state == :expr_dot
137
+ end
138
+
139
+ def expr_fname?
140
+ lex_state == :expr_fname
141
+ end
142
+
135
143
  def expr_result token, text
136
144
  cond.push false
137
145
  cmdarg.push false
@@ -304,28 +312,6 @@ class RubyLexer
304
312
  result :expr_end, :tBACK_REF, token
305
313
  end
306
314
 
307
- def process_backtick text
308
- case lex_state
309
- when :expr_fname then
310
- result :expr_end, :tBACK_REF2, "`"
311
- when :expr_dot then
312
- result((command_state ? :expr_cmdarg : :expr_arg), :tBACK_REF2, "`")
313
- else
314
- string STR_XQUOTE
315
- result nil, :tXSTRING_BEG, "`"
316
- end
317
- end
318
-
319
- def process_bang text
320
- if in_arg_state? then
321
- return result(:expr_arg, :tUBANG, "!@") if scan(/@/)
322
- end
323
-
324
- text = scan(/[=~]/) ? "!#{matched}" : "!"
325
-
326
- return result(arg_state, TOKENS[text], text)
327
- end
328
-
329
315
  def process_begin text
330
316
  @comments << matched
331
317
 
data/lib/ruby_lexer.rex CHANGED
@@ -44,139 +44,127 @@ rule
44
44
  /\n|\#/ process_newline_or_comment
45
45
 
46
46
  /[\]\)\}]/ process_bracing
47
- /\!/ process_bang
48
47
 
49
- /\.\.\.?|,|![=~]?/ { result :expr_beg, TOKENS[text], text }
48
+ : /\!/
49
+ | in_arg_state? /\!\@/ { result :expr_arg, :tUBANG, "!@" }
50
+ | /\![=~]?/ { result :arg_state, TOKENS[text], text }
50
51
 
51
- /\.\d/ { rb_compile_error "no .<digit> floating literal anymore put 0 before dot" }
52
-
53
- /\./ { result :expr_dot, :tDOT, "." }
52
+ : /\./
53
+ | /\.\.\.?/ { result :expr_beg, TOKENS[text], text }
54
+ | /\.\d/ { rb_compile_error "no .<digit> floating literal anymore put 0 before dot" }
55
+ | /\./ { result :expr_dot, :tDOT, "." }
54
56
 
55
57
  /\(/ process_paren
56
58
 
57
- /\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/ { result arg_state, TOKENS[text], text }
59
+ /\,/ { result :expr_beg, TOKENS[text], text }
58
60
 
59
- bol? /\=begin(?=\s)/ process_begin
60
- /\=(?=begin\b)/ { result arg_state, TOKENS[text], text }
61
+ : /=/
62
+ | /\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/ { result arg_state, TOKENS[text], text }
63
+ | bol? /\=begin(?=\s)/ process_begin
64
+ | /\=(?=begin\b)/ { result arg_state, TOKENS[text], text }
61
65
 
62
66
  /\"(#{SIMPLE_STRING})\"/o { result :expr_end, :tSTRING, text[1..-2].gsub(ESC) { unescape $1 } }
63
67
  /\"/ { string STR_DQUOTE; result nil, :tSTRING_BEG, text }
64
68
 
65
- /\@\@?\d/ { rb_compile_error "`#{text}` is not allowed as a variable name" }
69
+ /\@\@?\d/ { rb_compile_error "`#{text}` is not allowed as a variable name" }
66
70
  /\@\@?#{IDENT_CHAR}+/o process_ivar
67
71
 
68
- # /\:\:/ : happy? { result :expr_beg, :tCOLON3, text }
69
- # | { result :expr_beg, :tCOLON3, text }
70
- # /\:/ : trinary? { result :expr_beg, :tCOLON, text }
71
- # | /\'/ { string STR_SSYM; result :expr_fname, :tSYMBEG, text }
72
- # | /\"/ { string STR_DSYM; result :expr_fname, :tSYMBEG, text }
73
-
74
- not_end? /:([a-zA-Z_]#{IDENT_CHAR}*(?:[?]|[!](?!=)|=(?==>)|=(?![=>]))?)/o process_symbol
75
- not_end? /\:\"(#{SIMPLE_STRING})\"/o process_symbol
76
- not_end? /\:\'(#{SSTRING})\'/o process_symbol
77
-
78
- /\:\:/ process_colon2
79
- /\:/ process_colon1
80
-
81
- # numbers:
82
-
83
- # : /\d/
84
- # | /#{NUM_BAD}/o { rb_compile_error "Invalid numeric format" }
85
- # | /#{INT_DEC}/o { int_with_base 10 }
86
- # | /#{INT_HEX}/o { int_with_base 16 }
87
- # | /#{INT_BIN}/o { int_with_base 2 }
88
- # | /#{INT_OCT_BAD}/o { rb_compile_error "Illegal octal digit." }
89
- # | /#{INT_OCT}/o { int_with_base 8 }
90
- # | /#{FLOAT_BAD}/o { rb_compile_error "Trailing '_' in number." }
91
- # | /#{FLOAT}/o process_float
92
- # | /#{INT_DEC2}/o { int_with_base 10 }
72
+ : /:/
73
+ | not_end? /:([a-zA-Z_]#{IDENT_CHAR}*(?:[?]|[!](?!=)|=(?==>)|=(?![=>]))?)/o process_symbol
74
+ | not_end? /\:\"(#{SIMPLE_STRING})\"/o process_symbol
75
+ | not_end? /\:\'(#{SSTRING})\'/o process_symbol
76
+ | /\:\:/ process_colon2
77
+ | /\:/ process_colon1
93
78
 
94
79
  /->/ { result :expr_endfn, :tLAMBDA, nil }
95
80
 
96
81
  /[+-]/ process_plus_minus
97
82
 
98
- /#{NUM_BAD}/o { rb_compile_error "Invalid numeric format" }
99
- /#{INT_DEC}/o { int_with_base 10 }
100
- /#{INT_HEX}/o { int_with_base 16 }
101
- /#{INT_BIN}/o { int_with_base 2 }
102
- /#{INT_OCT_BAD}/o { rb_compile_error "Illegal octal digit." }
103
- /#{INT_OCT}/o { int_with_base 8 }
104
- /#{FLOAT_BAD}/o { rb_compile_error "Trailing '_' in number." }
105
- /#{FLOAT}/o process_float
106
- /#{INT_DEC2}/o { int_with_base 10 }
107
- /[0-9]/ { rb_compile_error "Bad number format" }
83
+ : /[+\d]/
84
+ | /#{NUM_BAD}/o { rb_compile_error "Invalid numeric format" }
85
+ | /#{INT_DEC}/o { int_with_base 10 }
86
+ | /#{INT_HEX}/o { int_with_base 16 }
87
+ | /#{INT_BIN}/o { int_with_base 2 }
88
+ | /#{INT_OCT_BAD}/o { rb_compile_error "Illegal octal digit." }
89
+ | /#{INT_OCT}/o { int_with_base 8 }
90
+ | /#{FLOAT_BAD}/o { rb_compile_error "Trailing '_' in number." }
91
+ | /#{FLOAT}/o process_float
92
+ | /#{INT_DEC2}/o { int_with_base 10 }
93
+ | /[0-9]/ { rb_compile_error "Bad number format" }
108
94
 
109
95
  /\[/ process_square_bracket
110
96
 
111
97
  /\'#{SSTRING}\'/o { result :expr_end, :tSTRING, matched[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'") } # " stupid emacs
112
98
 
113
- /\|\|\=/ { result :expr_beg, :tOP_ASGN, "||" }
114
- /\|\|/ { result :expr_beg, :tOROP, "||" }
115
- /\|\=/ { result :expr_beg, :tOP_ASGN, "|" }
116
- /\|/ { result :arg_state, :tPIPE, "|" }
99
+ : /\|/
100
+ | /\|\|\=/ { result :expr_beg, :tOP_ASGN, "||" }
101
+ | /\|\|/ { result :expr_beg, :tOROP, "||" }
102
+ | /\|\=/ { result :expr_beg, :tOP_ASGN, "|" }
103
+ | /\|/ { result :arg_state, :tPIPE, "|" }
117
104
 
118
105
  /\{/ process_curly_brace
119
106
 
120
- /\*\*=/ { result :expr_beg, :tOP_ASGN, "**" }
121
- /\*\*/ { result(:arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**") }
122
- /\*\=/ { result(:expr_beg, :tOP_ASGN, "*") }
123
- /\*/ { result(:arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*") }
124
-
125
- /\<\=\>/ { result :arg_state, :tCMP, "<=>" }
126
- /\<\=/ { result :arg_state, :tLEQ, "<=" }
127
- /\<\<\=/ { result :arg_state, :tOP_ASGN, "<<" }
128
- /\<\</ process_lchevron
129
- /\</ { result :arg_state, :tLT, "<" }
130
-
131
- # : /\>/
132
- # | /\>\=/ { result :arg_state, :tGEQ, ">=" }
133
- # | /\>\>=/ { result :arg_state, :tOP_ASGN, ">>" }
134
- # | /\>\>/ { result :arg_state, :tRSHFT, ">>" }
135
- # | /\>/ { result :arg_state, :tGT, ">" }
136
-
137
- /\>\=/ { result :arg_state, :tGEQ, ">=" }
138
- /\>\>=/ { result :arg_state, :tOP_ASGN, ">>" }
139
- /\>\>/ { result :arg_state, :tRSHFT, ">>" }
140
- /\>/ { result :arg_state, :tGT, ">" }
141
-
142
- /\`/ process_backtick
143
-
144
- # /\`/ : expr_fname? { result(:expr_end, :tBACK_REF2, "`") }
145
- # | expr_dot? { result((command_state ? :expr_cmdarg : :expr_arg), :tBACK_REF2, "`")
146
- # | { string STR_XQUOTE, '`'; result(nil, :tXSTRING_BEG, "`") }
107
+ : /\*/
108
+ | /\*\*=/ { result :expr_beg, :tOP_ASGN, "**" }
109
+ | /\*\*/ { result(:arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**") }
110
+ | /\*\=/ { result(:expr_beg, :tOP_ASGN, "*") }
111
+ | /\*/ { result(:arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*") }
112
+
113
+ : /</
114
+ | /\<\=\>/ { result :arg_state, :tCMP, "<=>" }
115
+ | /\<\=/ { result :arg_state, :tLEQ, "<=" }
116
+ | /\<\<\=/ { result :arg_state, :tOP_ASGN, "<<" }
117
+ | /\<\</ process_lchevron
118
+ | /\</ { result :arg_state, :tLT, "<" }
119
+
120
+ : />/
121
+ | /\>\=/ { result :arg_state, :tGEQ, ">=" }
122
+ | /\>\>=/ { result :arg_state, :tOP_ASGN, ">>" }
123
+ | /\>\>/ { result :arg_state, :tRSHFT, ">>" }
124
+ | /\>/ { result :arg_state, :tGT, ">" }
125
+
126
+ : /`/
127
+ | expr_fname? /\`/ { result(:expr_end, :tBACK_REF2, "`") }
128
+ | expr_dot? /\`/ { result((command_state ? :expr_cmdarg : :expr_arg), :tBACK_REF2, "`") }
129
+ | /\`/ { string STR_XQUOTE, '`'; result(nil, :tXSTRING_BEG, "`") }
147
130
 
148
131
  /\?/ process_questionmark
149
132
 
150
- /\&\&\=/ { result(:expr_beg, :tOP_ASGN, "&&") }
151
- /\&\&/ { result(:expr_beg, :tANDOP, "&&") }
152
- /\&\=/ { result(:expr_beg, :tOP_ASGN, "&" ) }
153
- /\&/ process_amper
133
+ : /&/
134
+ | /\&\&\=/ { result(:expr_beg, :tOP_ASGN, "&&") }
135
+ | /\&\&/ { result(:expr_beg, :tANDOP, "&&") }
136
+ | /\&\=/ { result(:expr_beg, :tOP_ASGN, "&" ) }
137
+ | /\&/ process_amper
154
138
 
155
139
  /\// process_slash
156
140
 
157
- /\^=/ { result(:expr_beg, :tOP_ASGN, "^") }
158
- /\^/ { result(:arg_state, :tCARET, "^") }
141
+ : /\^/
142
+ | /\^=/ { result(:expr_beg, :tOP_ASGN, "^") }
143
+ | /\^/ { result(:arg_state, :tCARET, "^") }
159
144
 
160
145
  /\;/ { self.command_start = true; result(:expr_beg, :tSEMI, ";") }
161
146
 
162
- in_arg_state? /\~@/ { result(:arg_state, :tTILDE, "~") }
163
- /\~/ { result(:arg_state, :tTILDE, "~") }
147
+ : /~/
148
+ | in_arg_state? /\~@/ { result(:arg_state, :tTILDE, "~") }
149
+ | /\~/ { result(:arg_state, :tTILDE, "~") }
164
150
 
165
- /\\\r?\n/ { self.lineno += 1; self.space_seen = true; next }
166
- /\\/ { rb_compile_error "bare backslash only allowed before newline" }
151
+ : /\\/
152
+ | /\\\r?\n/ { self.lineno += 1; self.space_seen = true; next }
153
+ | /\\/ { rb_compile_error "bare backslash only allowed before newline" }
167
154
 
168
155
  /\%/ process_percent
169
156
 
170
- /\$_\w+/ process_gvar
171
- /\$_/ process_gvar
172
- /\$[~*$?!@\/\\;,.=:<>\"]|\$-\w?/ process_gvar
173
- in_fname? /\$([\&\`\'\+])/ process_gvar
174
- /\$([\&\`\'\+])/ process_backref
175
- in_fname? /\$([1-9]\d*)/ process_gvar
176
- /\$([1-9]\d*)/ process_nthref
177
- /\$0/ process_gvar
178
- /\$\W|\$\z/ process_gvar_oddity
179
- /\$\w+/ process_gvar
157
+ : /\$/
158
+ | /\$_\w+/ process_gvar
159
+ | /\$_/ process_gvar
160
+ | /\$[~*$?!@\/\\;,.=:<>\"]|\$-\w?/ process_gvar
161
+ | in_fname? /\$([\&\`\'\+])/ process_gvar
162
+ | /\$([\&\`\'\+])/ process_backref
163
+ | in_fname? /\$([1-9]\d*)/ process_gvar
164
+ | /\$([1-9]\d*)/ process_nthref
165
+ | /\$0/ process_gvar
166
+ | /\$\W|\$\z/ process_gvar_oddity
167
+ | /\$\w+/ process_gvar
180
168
 
181
169
  /\_/ process_underscore
182
170
 
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # This file is automatically generated. Do not modify it.
3
- # Generated by: oedipus_lex version 2.1.0.
3
+ # Generated by: oedipus_lex version 2.2.0.
4
4
  # Source: lib/ruby_lexer.rex
5
5
  #++
6
6
 
@@ -85,22 +85,35 @@ class RubyLexer
85
85
  process_newline_or_comment text
86
86
  when text = ss.scan(/[\]\)\}]/) then
87
87
  process_bracing text
88
- when text = ss.scan(/\!/) then
89
- process_bang text
90
- when text = ss.scan(/\.\.\.?|,|![=~]?/) then
91
- action { result :expr_beg, TOKENS[text], text }
92
- when text = ss.scan(/\.\d/) then
93
- action { rb_compile_error "no .<digit> floating literal anymore put 0 before dot" }
94
- when text = ss.scan(/\./) then
95
- action { result :expr_dot, :tDOT, "." }
88
+ when ss.check(/\!/) then
89
+ case
90
+ when in_arg_state? && (text = ss.scan(/\!\@/)) then
91
+ action { result :expr_arg, :tUBANG, "!@" }
92
+ when text = ss.scan(/\![=~]?/) then
93
+ action { result :arg_state, TOKENS[text], text }
94
+ end # group /\!/
95
+ when ss.check(/\./) then
96
+ case
97
+ when text = ss.scan(/\.\.\.?/) then
98
+ action { result :expr_beg, TOKENS[text], text }
99
+ when text = ss.scan(/\.\d/) then
100
+ action { rb_compile_error "no .<digit> floating literal anymore put 0 before dot" }
101
+ when text = ss.scan(/\./) then
102
+ action { result :expr_dot, :tDOT, "." }
103
+ end # group /\./
96
104
  when text = ss.scan(/\(/) then
97
105
  process_paren text
98
- when text = ss.scan(/\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/) then
99
- action { result arg_state, TOKENS[text], text }
100
- when bol? && (text = ss.scan(/\=begin(?=\s)/)) then
101
- process_begin text
102
- when text = ss.scan(/\=(?=begin\b)/) then
103
- action { result arg_state, TOKENS[text], text }
106
+ when text = ss.scan(/\,/) then
107
+ action { result :expr_beg, TOKENS[text], text }
108
+ when ss.check(/=/) then
109
+ case
110
+ when text = ss.scan(/\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/) then
111
+ action { result arg_state, TOKENS[text], text }
112
+ when bol? && (text = ss.scan(/\=begin(?=\s)/)) then
113
+ process_begin text
114
+ when text = ss.scan(/\=(?=begin\b)/) then
115
+ action { result arg_state, TOKENS[text], text }
116
+ end # group /=/
104
117
  when text = ss.scan(/\"(#{SIMPLE_STRING})\"/o) then
105
118
  action { result :expr_end, :tSTRING, text[1..-2].gsub(ESC) { unescape $1 } }
106
119
  when text = ss.scan(/\"/) then
@@ -109,130 +122,170 @@ class RubyLexer
109
122
  action { rb_compile_error "`#{text}` is not allowed as a variable name" }
110
123
  when text = ss.scan(/\@\@?#{IDENT_CHAR}+/o) then
111
124
  process_ivar text
112
- when not_end? && (text = ss.scan(/:([a-zA-Z_]#{IDENT_CHAR}*(?:[?]|[!](?!=)|=(?==>)|=(?![=>]))?)/o)) then
113
- process_symbol text
114
- when not_end? && (text = ss.scan(/\:\"(#{SIMPLE_STRING})\"/o)) then
115
- process_symbol text
116
- when not_end? && (text = ss.scan(/\:\'(#{SSTRING})\'/o)) then
117
- process_symbol text
118
- when text = ss.scan(/\:\:/) then
119
- process_colon2 text
120
- when text = ss.scan(/\:/) then
121
- process_colon1 text
125
+ when ss.check(/:/) then
126
+ case
127
+ when not_end? && (text = ss.scan(/:([a-zA-Z_]#{IDENT_CHAR}*(?:[?]|[!](?!=)|=(?==>)|=(?![=>]))?)/o)) then
128
+ process_symbol text
129
+ when not_end? && (text = ss.scan(/\:\"(#{SIMPLE_STRING})\"/o)) then
130
+ process_symbol text
131
+ when not_end? && (text = ss.scan(/\:\'(#{SSTRING})\'/o)) then
132
+ process_symbol text
133
+ when text = ss.scan(/\:\:/) then
134
+ process_colon2 text
135
+ when text = ss.scan(/\:/) then
136
+ process_colon1 text
137
+ end # group /:/
122
138
  when text = ss.scan(/->/) then
123
139
  action { result :expr_endfn, :tLAMBDA, nil }
124
140
  when text = ss.scan(/[+-]/) then
125
141
  process_plus_minus text
126
- when text = ss.scan(/#{NUM_BAD}/o) then
127
- action { rb_compile_error "Invalid numeric format" }
128
- when text = ss.scan(/#{INT_DEC}/o) then
129
- action { int_with_base 10 }
130
- when text = ss.scan(/#{INT_HEX}/o) then
131
- action { int_with_base 16 }
132
- when text = ss.scan(/#{INT_BIN}/o) then
133
- action { int_with_base 2 }
134
- when text = ss.scan(/#{INT_OCT_BAD}/o) then
135
- action { rb_compile_error "Illegal octal digit." }
136
- when text = ss.scan(/#{INT_OCT}/o) then
137
- action { int_with_base 8 }
138
- when text = ss.scan(/#{FLOAT_BAD}/o) then
139
- action { rb_compile_error "Trailing '_' in number." }
140
- when text = ss.scan(/#{FLOAT}/o) then
141
- process_float text
142
- when text = ss.scan(/#{INT_DEC2}/o) then
143
- action { int_with_base 10 }
144
- when text = ss.scan(/[0-9]/) then
145
- action { rb_compile_error "Bad number format" }
142
+ when ss.check(/[+\d]/) then
143
+ case
144
+ when text = ss.scan(/#{NUM_BAD}/o) then
145
+ action { rb_compile_error "Invalid numeric format" }
146
+ when text = ss.scan(/#{INT_DEC}/o) then
147
+ action { int_with_base 10 }
148
+ when text = ss.scan(/#{INT_HEX}/o) then
149
+ action { int_with_base 16 }
150
+ when text = ss.scan(/#{INT_BIN}/o) then
151
+ action { int_with_base 2 }
152
+ when text = ss.scan(/#{INT_OCT_BAD}/o) then
153
+ action { rb_compile_error "Illegal octal digit." }
154
+ when text = ss.scan(/#{INT_OCT}/o) then
155
+ action { int_with_base 8 }
156
+ when text = ss.scan(/#{FLOAT_BAD}/o) then
157
+ action { rb_compile_error "Trailing '_' in number." }
158
+ when text = ss.scan(/#{FLOAT}/o) then
159
+ process_float text
160
+ when text = ss.scan(/#{INT_DEC2}/o) then
161
+ action { int_with_base 10 }
162
+ when text = ss.scan(/[0-9]/) then
163
+ action { rb_compile_error "Bad number format" }
164
+ end # group /[+\d]/
146
165
  when text = ss.scan(/\[/) then
147
166
  process_square_bracket text
148
167
  when text = ss.scan(/\'#{SSTRING}\'/o) then
149
168
  action { result :expr_end, :tSTRING, matched[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'") } # " stupid emacs
150
- when text = ss.scan(/\|\|\=/) then
151
- action { result :expr_beg, :tOP_ASGN, "||" }
152
- when text = ss.scan(/\|\|/) then
153
- action { result :expr_beg, :tOROP, "||" }
154
- when text = ss.scan(/\|\=/) then
155
- action { result :expr_beg, :tOP_ASGN, "|" }
156
- when text = ss.scan(/\|/) then
157
- action { result :arg_state, :tPIPE, "|" }
169
+ when ss.check(/\|/) then
170
+ case
171
+ when text = ss.scan(/\|\|\=/) then
172
+ action { result :expr_beg, :tOP_ASGN, "||" }
173
+ when text = ss.scan(/\|\|/) then
174
+ action { result :expr_beg, :tOROP, "||" }
175
+ when text = ss.scan(/\|\=/) then
176
+ action { result :expr_beg, :tOP_ASGN, "|" }
177
+ when text = ss.scan(/\|/) then
178
+ action { result :arg_state, :tPIPE, "|" }
179
+ end # group /\|/
158
180
  when text = ss.scan(/\{/) then
159
181
  process_curly_brace text
160
- when text = ss.scan(/\*\*=/) then
161
- action { result :expr_beg, :tOP_ASGN, "**" }
162
- when text = ss.scan(/\*\*/) then
163
- action { result(:arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**") }
164
- when text = ss.scan(/\*\=/) then
165
- action { result(:expr_beg, :tOP_ASGN, "*") }
166
- when text = ss.scan(/\*/) then
167
- action { result(:arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*") }
168
- when text = ss.scan(/\<\=\>/) then
169
- action { result :arg_state, :tCMP, "<=>" }
170
- when text = ss.scan(/\<\=/) then
171
- action { result :arg_state, :tLEQ, "<=" }
172
- when text = ss.scan(/\<\<\=/) then
173
- action { result :arg_state, :tOP_ASGN, "<<" }
174
- when text = ss.scan(/\<\</) then
175
- process_lchevron text
176
- when text = ss.scan(/\</) then
177
- action { result :arg_state, :tLT, "<" }
178
- when text = ss.scan(/\>\=/) then
179
- action { result :arg_state, :tGEQ, ">=" }
180
- when text = ss.scan(/\>\>=/) then
181
- action { result :arg_state, :tOP_ASGN, ">>" }
182
- when text = ss.scan(/\>\>/) then
183
- action { result :arg_state, :tRSHFT, ">>" }
184
- when text = ss.scan(/\>/) then
185
- action { result :arg_state, :tGT, ">" }
186
- when text = ss.scan(/\`/) then
187
- process_backtick text
182
+ when ss.check(/\*/) then
183
+ case
184
+ when text = ss.scan(/\*\*=/) then
185
+ action { result :expr_beg, :tOP_ASGN, "**" }
186
+ when text = ss.scan(/\*\*/) then
187
+ action { result(:arg_state, space_vs_beginning(:tDSTAR, :tDSTAR, :tPOW), "**") }
188
+ when text = ss.scan(/\*\=/) then
189
+ action { result(:expr_beg, :tOP_ASGN, "*") }
190
+ when text = ss.scan(/\*/) then
191
+ action { result(:arg_state, space_vs_beginning(:tSTAR, :tSTAR, :tSTAR2), "*") }
192
+ end # group /\*/
193
+ when ss.check(/</) then
194
+ case
195
+ when text = ss.scan(/\<\=\>/) then
196
+ action { result :arg_state, :tCMP, "<=>" }
197
+ when text = ss.scan(/\<\=/) then
198
+ action { result :arg_state, :tLEQ, "<=" }
199
+ when text = ss.scan(/\<\<\=/) then
200
+ action { result :arg_state, :tOP_ASGN, "<<" }
201
+ when text = ss.scan(/\<\</) then
202
+ process_lchevron text
203
+ when text = ss.scan(/\</) then
204
+ action { result :arg_state, :tLT, "<" }
205
+ end # group /</
206
+ when ss.check(/>/) then
207
+ case
208
+ when text = ss.scan(/\>\=/) then
209
+ action { result :arg_state, :tGEQ, ">=" }
210
+ when text = ss.scan(/\>\>=/) then
211
+ action { result :arg_state, :tOP_ASGN, ">>" }
212
+ when text = ss.scan(/\>\>/) then
213
+ action { result :arg_state, :tRSHFT, ">>" }
214
+ when text = ss.scan(/\>/) then
215
+ action { result :arg_state, :tGT, ">" }
216
+ end # group />/
217
+ when ss.check(/`/) then
218
+ case
219
+ when expr_fname? && (text = ss.scan(/\`/)) then
220
+ action { result(:expr_end, :tBACK_REF2, "`") }
221
+ when expr_dot? && (text = ss.scan(/\`/)) then
222
+ action { result((command_state ? :expr_cmdarg : :expr_arg), :tBACK_REF2, "`") }
223
+ when text = ss.scan(/\`/) then
224
+ action { string STR_XQUOTE, '`'; result(nil, :tXSTRING_BEG, "`") }
225
+ end # group /`/
188
226
  when text = ss.scan(/\?/) then
189
227
  process_questionmark text
190
- when text = ss.scan(/\&\&\=/) then
191
- action { result(:expr_beg, :tOP_ASGN, "&&") }
192
- when text = ss.scan(/\&\&/) then
193
- action { result(:expr_beg, :tANDOP, "&&") }
194
- when text = ss.scan(/\&\=/) then
195
- action { result(:expr_beg, :tOP_ASGN, "&" ) }
196
- when text = ss.scan(/\&/) then
197
- process_amper text
228
+ when ss.check(/&/) then
229
+ case
230
+ when text = ss.scan(/\&\&\=/) then
231
+ action { result(:expr_beg, :tOP_ASGN, "&&") }
232
+ when text = ss.scan(/\&\&/) then
233
+ action { result(:expr_beg, :tANDOP, "&&") }
234
+ when text = ss.scan(/\&\=/) then
235
+ action { result(:expr_beg, :tOP_ASGN, "&" ) }
236
+ when text = ss.scan(/\&/) then
237
+ process_amper text
238
+ end # group /&/
198
239
  when text = ss.scan(/\//) then
199
240
  process_slash text
200
- when text = ss.scan(/\^=/) then
201
- action { result(:expr_beg, :tOP_ASGN, "^") }
202
- when text = ss.scan(/\^/) then
203
- action { result(:arg_state, :tCARET, "^") }
241
+ when ss.check(/\^/) then
242
+ case
243
+ when text = ss.scan(/\^=/) then
244
+ action { result(:expr_beg, :tOP_ASGN, "^") }
245
+ when text = ss.scan(/\^/) then
246
+ action { result(:arg_state, :tCARET, "^") }
247
+ end # group /\^/
204
248
  when text = ss.scan(/\;/) then
205
249
  action { self.command_start = true; result(:expr_beg, :tSEMI, ";") }
206
- when in_arg_state? && (text = ss.scan(/\~@/)) then
207
- action { result(:arg_state, :tTILDE, "~") }
208
- when text = ss.scan(/\~/) then
209
- action { result(:arg_state, :tTILDE, "~") }
210
- when text = ss.scan(/\\\r?\n/) then
211
- action { self.lineno += 1; self.space_seen = true; next }
212
- when text = ss.scan(/\\/) then
213
- action { rb_compile_error "bare backslash only allowed before newline" }
250
+ when ss.check(/~/) then
251
+ case
252
+ when in_arg_state? && (text = ss.scan(/\~@/)) then
253
+ action { result(:arg_state, :tTILDE, "~") }
254
+ when text = ss.scan(/\~/) then
255
+ action { result(:arg_state, :tTILDE, "~") }
256
+ end # group /~/
257
+ when ss.check(/\\/) then
258
+ case
259
+ when text = ss.scan(/\\\r?\n/) then
260
+ action { self.lineno += 1; self.space_seen = true; next }
261
+ when text = ss.scan(/\\/) then
262
+ action { rb_compile_error "bare backslash only allowed before newline" }
263
+ end # group /\\/
214
264
  when text = ss.scan(/\%/) then
215
265
  process_percent text
216
- when text = ss.scan(/\$_\w+/) then
217
- process_gvar text
218
- when text = ss.scan(/\$_/) then
219
- process_gvar text
220
- when text = ss.scan(/\$[~*$?!@\/\\;,.=:<>\"]|\$-\w?/) then
221
- process_gvar text
222
- when in_fname? && (text = ss.scan(/\$([\&\`\'\+])/)) then
223
- process_gvar text
224
- when text = ss.scan(/\$([\&\`\'\+])/) then
225
- process_backref text
226
- when in_fname? && (text = ss.scan(/\$([1-9]\d*)/)) then
227
- process_gvar text
228
- when text = ss.scan(/\$([1-9]\d*)/) then
229
- process_nthref text
230
- when text = ss.scan(/\$0/) then
231
- process_gvar text
232
- when text = ss.scan(/\$\W|\$\z/) then
233
- process_gvar_oddity text
234
- when text = ss.scan(/\$\w+/) then
235
- process_gvar text
266
+ when ss.check(/\$/) then
267
+ case
268
+ when text = ss.scan(/\$_\w+/) then
269
+ process_gvar text
270
+ when text = ss.scan(/\$_/) then
271
+ process_gvar text
272
+ when text = ss.scan(/\$[~*$?!@\/\\;,.=:<>\"]|\$-\w?/) then
273
+ process_gvar text
274
+ when in_fname? && (text = ss.scan(/\$([\&\`\'\+])/)) then
275
+ process_gvar text
276
+ when text = ss.scan(/\$([\&\`\'\+])/) then
277
+ process_backref text
278
+ when in_fname? && (text = ss.scan(/\$([1-9]\d*)/)) then
279
+ process_gvar text
280
+ when text = ss.scan(/\$([1-9]\d*)/) then
281
+ process_nthref text
282
+ when text = ss.scan(/\$0/) then
283
+ process_gvar text
284
+ when text = ss.scan(/\$\W|\$\z/) then
285
+ process_gvar_oddity text
286
+ when text = ss.scan(/\$\w+/) then
287
+ process_gvar text
288
+ end # group /\$/
236
289
  when text = ss.scan(/\_/) then
237
290
  process_underscore text
238
291
  when text = ss.scan(/#{IDENT}/o) then