NoMatch reports line,col, but debug messages report position.
StyXman opened this issue · comments
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.
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.