You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from arpeggio import ZeroOrMore, RegExMatch, StrMatch, EOF
from arpeggio import ParserPython
class SuppressStrMatch(StrMatch):
suppress = True
#newline = StrMatch('\n') # with this i get a successful parse
newline = SuppressStrMatch('\n') # with this i get a NoMatch at (3, 1)
def line(): return RegExMatch(r'^.*$'), newline
def grammar(): return ZeroOrMore(line), EOF
parser = ParserPython(grammar, debug=True, skipws=False)
result = parser.parse('one\n\nthree\nfour\n')
print(result.tree_str())
Running this with 'Arpeggio==2.0.0' gives me arpeggio.NoMatch: Expected EOF at position (3, 1) => 'one\n\n*three\nfour'. When I use newline = StrMatch('\n') instead of the suppressed newline = SuppressStrMatch('\n') the input is parsed with success. Seems to be a problem with suppress altering parser behaviour?
The text was updated successfully, but these errors were encountered:
Thanks for the report and the reduced example. I confirm that it is a bug. At first glance it seems that it is a bad interplay between the ZeroOrMore rule and suppressed match. Zero or more thinks that the suppressed rule match is not successful and tries to continue by matching EOF.
Hi! I have a grammar where newlines matter but I don't want the newlines to be part of the parse tree. Tried to suppress the newlines using http://textx.github.io/Arpeggio/2.0/parse_trees/#suppressing-parse-tree-nodes but hit a wall.
Here's my reduced example:
Running this with 'Arpeggio==2.0.0' gives me
arpeggio.NoMatch: Expected EOF at position (3, 1) => 'one\n\n*three\nfour'
. When I usenewline = StrMatch('\n')
instead of the suppressednewline = SuppressStrMatch('\n')
the input is parsed with success. Seems to be a problem with suppress altering parser behaviour?The text was updated successfully, but these errors were encountered: