Paul McGuire wrote: > 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.
Thanks, that's exactly what I was looking for. > 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. Yeah, sorry, I was still messing around with that part of the code. My problem is that I have to differentiate between: (NP -x-y) and: (NP-x -y) I'm doing this now using Combine. Does that seem right? > 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) I think I'm okay: py> 2 << 1 + 2 16 py> (2 << 1) + 2 6 py> 2 << (1 + 2) 16 Thanks for the help! STeVe -- http://mail.python.org/mailman/listinfo/python-list