@@ -57,10 +57,10 @@ def setup
5757 def scan_tokens ( encoder , options )
5858 @encoder = encoder
5959 @options = options
60-
60+
6161 until eos?
6262 case state
63-
63+
6464 when :initial
6565 if match = scan ( /\- \- \[ \= *\[ / ) #--[[ long (possibly multiline) comment ]]
6666 @num_equals = match . count ( "=" ) # Number must match for comment end
@@ -144,7 +144,7 @@ def scan_tokens(encoder, options)
144144 # (tables can contain full expressions in parts).
145145 # If this is the case, return to :table scanning state.
146146 @state = :table if @state == :initial && @brace_depth >= 1
147-
147+
148148 when :function_expected
149149 if match = scan ( /\( .*?\) /m ) # x = function() # "Anonymous" function without explicit name
150150 @encoder . text_token ( match , :operator )
@@ -170,7 +170,7 @@ def scan_tokens(encoder, options)
170170 else
171171 @encoder . text_token ( getch , :error )
172172 end
173-
173+
174174 when :local_var_expected
175175 if match = scan ( /function/ ) # local function ...
176176 @encoder . text_token ( match , :keyword )
@@ -179,7 +179,7 @@ def scan_tokens(encoder, options)
179179 @encoder . text_token ( match , :local_variable )
180180 elsif match = scan ( /,/ )
181181 @encoder . text_token ( match , :operator )
182- elsif match = scan ( /=/ )
182+ elsif match = scan ( /\ = / )
183183 @encoder . text_token ( match , :operator )
184184 # After encountering the equal sign, arbitrary expressions are
185185 # allowed again, so just return to the main state for further
@@ -193,7 +193,7 @@ def scan_tokens(encoder, options)
193193 else
194194 @encoder . text_token ( getch , :error )
195195 end
196-
196+
197197 when :long_comment
198198 if match = scan ( /.*?(?=\] ={#@num_equals }\] )/m )
199199 @encoder . text_token ( match , :content )
@@ -206,7 +206,7 @@ def scan_tokens(encoder, options)
206206 end
207207 @encoder . end_group ( :comment )
208208 @state = :initial
209-
209+
210210 when :long_string
211211 if match = scan ( /.*?(?=\] ={#@num_equals }\] )/m ) # Long strings do not interpret any escape sequences
212212 @encoder . text_token ( match , :content )
@@ -219,7 +219,7 @@ def scan_tokens(encoder, options)
219219 end
220220 @encoder . end_group ( :string )
221221 @state = :initial
222-
222+
223223 when :string
224224 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)
225225 @encoder . text_token ( match , :content )
@@ -236,14 +236,14 @@ def scan_tokens(encoder, options)
236236 else
237237 @encoder . text_token ( getch , :error )
238238 end
239-
239+
240240 when :table
241241 if match = scan ( /[,;]/ )
242242 @encoder . text_token ( match , :operator )
243243 elsif match = scan ( /[a-zA-Z_][a-zA-Z0-9_]* (?=\s *=)/x )
244244 @encoder . text_token ( match , :key )
245245 @encoder . text_token ( scan ( /\s +/ ) , :space ) if check ( /\s +/ )
246- @encoder . text_token ( scan ( /=/ ) , :operator )
246+ @encoder . text_token ( scan ( /\ = / ) , :operator )
247247 @state = :initial
248248 elsif match = scan ( /\s +/m )
249249 @encoder . text_token ( match , :space )
0 commit comments