Pyparsing Question

Paul McGuire ptmcg at austin.rr.com
Fri May 16 11:37:44 EDT 2008


On May 16, 6:43 am, Ant <ant... at gmail.com> wrote:
> Hi all,
>
> I have a question on PyParsing. I am trying to create a parser for a
> hierarchical todo list format, but have hit a stumbling block. I have
> parsers for the header of the list (title and description), and the body
> (recursive descent on todo items).
>

LineStart *really* wants to be parsed at the beginning of a line.
Your textline reads up to but not including the LineEnd.  Try making
these changes.

1. Change textline to:

     textline = pp.Combine(
        pp.Group(pp.Word(pp.alphas, pp.printables) + pp.restOfLine)) +
\
        pp.LineEnd().suppress()

2. Change comb to:

    comb = head + parser

With these changes, my version of your code runs ok.

-- Paul



More information about the Python-list mailing list