Question

This is just a toy grammar to test backtracking:

from pyparsing import *
a = Literal("a")
b = Literal("b")
c = Literal("c")

abb = a + b + b
abc = a + b + c
aba = a + b + a

grammar = MatchFirst( [ abb.setDebug(), abc.setDebug(), aba.setDebug() ] )
grammar.parseString( "aba" )

With packrat disabled, the returned parse tree

['a', 'b', 'a']

With packrat enabled, I get

['a', 'b', 'b', 'a']

Why is this happening, in the last case ? Thanks

Was it helpful?

Solution

This is a bug in pyparsing. Corrected version has been checked into SVN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top