A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/308644.html below:

make sure entire string was parsed

make sure entire string was parsed make sure entire string was parsedPaul McGuire ptmcg at austin.rr.com
Sat Sep 10 22:17:16 EDT 2005
Steven -

Thanks for giving pyparsing a try!  To see whether your input text
consumes the whole string, add a StringEnd() element to the end of your
BNF.  Then if there is more text after the parsed text, parseString
will throw a ParseException.

I notice you call leaveWhitespace on several of your parse elements, so
you may have to rstrip() the input text before calling parseString.  I
am curious whether leaveWhitespace is really necessary for your
grammar.  If it is, you can usually just call leaveWhitespace on the
root element, and this will propagate to all the sub elements.

Lastly, you may get caught up with operator precedence, I think your
node assignment statement may need to change from
    node << start + (branch_node | leaf_node) + end
to
    node << (start + (branch_node | leaf_node) + end)

HTH, 
-- Paul


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4