trouble pyparsing

the.theorist the.theorist at gmail.com
Wed Jan 4 23:01:41 EST 2006


Boy, do I feel sheepish. Yes, what I wanted were Literals. That
clarifies things greatly. Thank you.

Also, I went browsing around further, and found on O'reilly's CodeZoo:
Most of the methods in the pyparsing module are very easy to figure
out. Forward() might not be as obvious. To get going with it, think of
the Forward() method as declaring a recursive match. Start out by
defining the match variable with the Forward() method (with no
arguments). Then use the '<<' operator to define the actual match --
and use the match variable itself in the definition to show where
recursion would occur. See the code sample below for an example.
# Parser definition for simple
# SGML snippet
container_tag = Forward()
open_tag, close_tag = tag()
content_tag = tag(closed=False)
content = Group(open_tag + CharsNotIn("<"))
container_tag << Group(open_tag + OneOrMore(container_tag | content) +
close_tag)
#     ^name
 ^recursive reference
body = Group(container_tag).setResultsName("body")

So, I think that clears things up on both issues.

Again, Thank you for your assistance.




More information about the Python-list mailing list