textX / Arpeggio

Parser interpreter based on PEG grammars written in Python http://textx.github.io/Arpeggio/
Other
268 stars 55 forks source link

Lookahead rules always showed as not matched in debug mode #95

Open vprat opened 2 years ago

vprat commented 2 years ago

And and Not rules are never showed as matched in debug mode because no input is consumed. This is misleading.

>>> from arpeggio import *
>>> def expr(): return And("a"), "a"           
... 
>>> p = ParserPython(expr)
>>> p.debug = True
>>> p.parse("a")
>> Matching rule expr=Sequence at position 0 => *a
   >> Matching rule And in expr at position 0 => *a
      ?? Try match rule StrMatch(a) in expr at position 0 => *a
      ++ Match 'a' at 0 => '*a*'
   <<- Not matched rule And in expr at position 0 => *a
   ?? Try match rule StrMatch(a) in expr at position 0 => *a
   ++ Match 'a' at 0 => '*a*'
<<+ Matched rule expr=Sequence in expr at position 1 => a*
[  'a' [0] ]
igordejanovic commented 2 years ago

Thanks for the report. It is indeed misleading.