@@ -57,10 +57,10 @@ def setup
57
57
def scan_tokens ( encoder , options )
58
58
@encoder = encoder
59
59
@options = options
60
-
60
+
61
61
until eos?
62
62
case state
63
-
63
+
64
64
when :initial
65
65
if match = scan ( /\- \- \[ \= *\[ / ) #--[[ long (possibly multiline) comment ]]
66
66
@num_equals = match . count ( "=" ) # Number must match for comment end
@@ -144,7 +144,7 @@ def scan_tokens(encoder, options)
144
144
# (tables can contain full expressions in parts).
145
145
# If this is the case, return to :table scanning state.
146
146
@state = :table if @state == :initial && @brace_depth >= 1
147
-
147
+
148
148
when :function_expected
149
149
if match = scan ( /\( .*?\) /m ) # x = function() # "Anonymous" function without explicit name
150
150
@encoder . text_token ( match , :operator )
@@ -170,7 +170,7 @@ def scan_tokens(encoder, options)
170
170
else
171
171
@encoder . text_token ( getch , :error )
172
172
end
173
-
173
+
174
174
when :local_var_expected
175
175
if match = scan ( /function/ ) # local function ...
176
176
@encoder . text_token ( match , :keyword )
@@ -179,7 +179,7 @@ def scan_tokens(encoder, options)
179
179
@encoder . text_token ( match , :local_variable )
180
180
elsif match = scan ( /,/ )
181
181
@encoder . text_token ( match , :operator )
182
- elsif match = scan ( /=/ )
182
+ elsif match = scan ( /\ = / )
183
183
@encoder . text_token ( match , :operator )
184
184
# After encountering the equal sign, arbitrary expressions are
185
185
# allowed again, so just return to the main state for further
@@ -193,7 +193,7 @@ def scan_tokens(encoder, options)
193
193
else
194
194
@encoder . text_token ( getch , :error )
195
195
end
196
-
196
+
197
197
when :long_comment
198
198
if match = scan ( /.*?(?=\] ={#@num_equals }\] )/m )
199
199
@encoder . text_token ( match , :content )
@@ -206,7 +206,7 @@ def scan_tokens(encoder, options)
206
206
end
207
207
@encoder . end_group ( :comment )
208
208
@state = :initial
209
-
209
+
210
210
when :long_string
211
211
if match = scan ( /.*?(?=\] ={#@num_equals }\] )/m ) # Long strings do not interpret any escape sequences
212
212
@encoder . text_token ( match , :content )
@@ -219,7 +219,7 @@ def scan_tokens(encoder, options)
219
219
end
220
220
@encoder . end_group ( :string )
221
221
@state = :initial
222
-
222
+
223
223
when :string
224
224
if match = scan ( /[^\\ #@start_delim \n ]+/ ) # Everything except \ and the start delimiter character is string content (newlines are only allowed if preceeded by \ or \z)
225
225
@encoder . text_token ( match , :content )
@@ -236,14 +236,14 @@ def scan_tokens(encoder, options)
236
236
else
237
237
@encoder . text_token ( getch , :error )
238
238
end
239
-
239
+
240
240
when :table
241
241
if match = scan ( /[,;]/ )
242
242
@encoder . text_token ( match , :operator )
243
243
elsif match = scan ( /[a-zA-Z_][a-zA-Z0-9_]* (?=\s *=)/x )
244
244
@encoder . text_token ( match , :key )
245
245
@encoder . text_token ( scan ( /\s +/ ) , :space ) if check ( /\s +/ )
246
- @encoder . text_token ( scan ( /=/ ) , :operator )
246
+ @encoder . text_token ( scan ( /\ = / ) , :operator )
247
247
@state = :initial
248
248
elsif match = scan ( /\s +/m )
249
249
@encoder . text_token ( match , :space )
0 commit comments