Arpeggio icon indicating copy to clipboard operation
Arpeggio copied to clipboard

NoMatch reports line,col, but debug messages report position.

Open StyXman opened this issue 5 years ago • 1 comments
trafficstars

From this page https://textx.github.io/Arpeggio/stable/handling_errors/ :

Traceback (most recent call last):
  ...
arpeggio.NoMatch: Expected '+' or '-' or 'number' or 
  '(' at position (1, 6) => '23+4/*r-89'.

But the debug messages show only the position in file (from another project I'm working on):

[...]
                                                                 ?? Try match rule StrMatch(:) in set_attribute at position 15638 => -dasharray*: @primary
                                                                  ++ Match ':' at 15638 => '-dasharray*:* @primary'
                                                                  >> Matching rule expression=OrderedChoice in set_attribute at position 15639 => dasharray:* @primary-
[...]

It would be nice that the debug messages also reported line+col, as many editors only support displaying that instead of position in file.

If you could point me to where the code should be changed, I could even try to do the patch myself.

StyXman avatar Mar 15 '20 15:03 StyXman

You can convert absolute position to line,col format by parser.pos_to_linecol and the use line,col in debug outputs (e.g. https://github.com/textX/Arpeggio/blob/master/arpeggio/init.py#L258)

The only concern is that it will incur a considerable overhead but since it's only for debugging I guess it's ok.

igordejanovic avatar Mar 19 '20 12:03 igordejanovic