@@ -307,25 +307,27 @@ def reset_instance
307
307
MESSAGE
308
308
309
309
# Scanner error with additional status information
310
- def raise_inspect msg , tokens , state = self . state , ambit = 30 , backtrace = caller
311
- raise ScanError , SCAN_ERROR_MESSAGE % [
312
- File . basename ( caller [ 0 ] ) ,
313
- msg ,
314
- tokens_size ,
315
- tokens_last ( 10 ) . map ( &:inspect ) . join ( "\n " ) ,
310
+ def raise_inspect message , tokens , state = self . state , ambit = 30 , backtrace = caller
311
+ raise ScanError , SCAN_ERROR_MESSAGE % raise_inspect_arguments ( message , tokens , state , ambit ) , backtrace
312
+ end
313
+
314
+ def raise_inspect_arguments message , tokens , state , ambit
315
+ return File . basename ( caller [ 0 ] ) ,
316
+ message ,
317
+ tokens_size ( tokens ) ,
318
+ tokens_last ( tokens , 10 ) . map ( &:inspect ) . join ( "\n " ) ,
316
319
line , column , pos ,
317
320
matched , state || 'No state given!' ,
318
321
bol? , eos? ,
319
322
binary_string [ pos - ambit , ambit ] ,
320
- binary_string [ pos , ambit ] ,
321
- ] , backtrace
323
+ binary_string [ pos , ambit ]
322
324
end
323
325
324
- def tokens_size
326
+ def tokens_size tokens
325
327
tokens . size if tokens . respond_to? ( :size )
326
328
end
327
329
328
- def tokens_last n
330
+ def tokens_last tokens , n
329
331
tokens . respond_to? ( :last ) ? tokens . last ( n ) : [ ]
330
332
end
331
333
0 commit comments