SimpleParse and LookAhead

yvan yvan_charpentier at
Tue Apr 1 06:42:38 CEST 2003


I must be missing something here. I was expecting the following script
to get me: 'root', it outputs 'oot'
Reading the docs, my understanding what that if '?' is a prefix, then
the parser object returns to the previous location. Is that right? If
not, how do i get that behaviour?

declaration = r'''line := ?([a-z], root)
root:= char

testdata = '''root - Dir
from simpleparse import generator

from mx.TextTools import TextTools

parser = generator.buildParser(declaration).parserbyname('line')

taglist = TextTools.tag(testdata, parser)

for tag, beg, end, parts in taglist[1]:

    print testdata[beg:end]

Any help appreciated,


More information about the Python-list mailing list