[Pyparsing] Beginner parsing problem
Brought to you by:
ptmcg
From: Florian L. <mai...@xg...> - 2013-01-05 10:40:38
|
Hello, I've just started working with pyparsing >>> from pyparsing import * text = """ FoamFile { version 2.0; format ascii; class volVectorField; object U; }""" text2 = " class volVectorField;" FKeyValue = Word(printables) + Word(printables) + ";" FDictionary = Word(printables) + "{" + OneOrMore( FKeyValue ) + "}" print FKeyValue.parseString(text2) # Works fine print FDictionary.parseString(text) # Fails <<< (I use the F prefix to avoid name clashes with pyparsing stuff, might change set and switch to more selective import). The last print fails: Traceback (most recent call last): File "parse.py", line 22, in <module> print FKeyValue.parseString(text2) File "/home/florian/scratch/pyparsing.py", line 1006, in parseString raise exc pyparsing.ParseException: Expected ";" (at char 28), (line:1, col:29) What is wrong there? If I understood the documentation right, newlines are ignored, just like whitespace. It's pyparsing downloaded from the 1.5.x svn branch. Thanks, Florian |