@@ -294,9 +294,7 @@ def reset_instance
294
294
tokens:
295
295
%s
296
296
297
- current line: %d column: %d pos: %d
298
- matched: %p state: %p
299
- bol?: %p, eos?: %p
297
+ %s
300
298
301
299
surrounding code:
302
300
%p ~~ %p
@@ -306,21 +304,33 @@ def reset_instance
306
304
307
305
MESSAGE
308
306
309
- # Scanner error with additional status information
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
307
def raise_inspect_arguments message , tokens , state , ambit
315
308
return File . basename ( caller [ 0 ] ) ,
316
309
message ,
317
310
tokens_size ( tokens ) ,
318
311
tokens_last ( tokens , 10 ) . map ( &:inspect ) . join ( "\n " ) ,
312
+ scanner_state_info ( state ) ,
313
+ binary_string [ pos - ambit , ambit ] ,
314
+ binary_string [ pos , ambit ]
315
+ end
316
+
317
+ SCANNER_STATE_INFO = <<-INFO
318
+ current line: %d column: %d pos: %d
319
+ matched: %p state: %p
320
+ bol?: %p, eos?: %p
321
+ INFO
322
+
323
+ def scanner_state_info state
324
+ SCANNER_STATE_INFO % [
319
325
line , column , pos ,
320
326
matched , state || 'No state given!' ,
321
327
bol? , eos? ,
322
- binary_string [ pos - ambit , ambit ] ,
323
- binary_string [ pos , ambit ]
328
+ ]
329
+ end
330
+
331
+ # Scanner error with additional status information
332
+ def raise_inspect message , tokens , state = self . state , ambit = 30 , backtrace = caller
333
+ raise ScanError , SCAN_ERROR_MESSAGE % raise_inspect_arguments ( message , tokens , state , ambit ) , backtrace
324
334
end
325
335
326
336
def tokens_size tokens
0 commit comments