Re: [Pyparsing] A newbie w/nested structures
Brought to you by:
ptmcg
From: Tim C. <tim...@gm...> - 2007-09-09 10:48:01
|
Hi Paul, On Sun, 2007-09-09 at 04:30 -0500, Paul McGuire wrote: > Here are some suggestions on getting started: > - pick a part of the sample ADL (I would suggest working section by section) > - develop a simple BNF for this grammar > > Here is a sample parser for the ontology section. This is exactly what I started with. Well, it's what I dropped back to when I realized how difficult it would be. :-) > It is a recursive > example, defining a valueDef that is defined in terms of component > valueDefs. It also shows the comment format, and the mechanism for skipping > comments. I hope this sample gives you a jump start on a more complete ADL > parser. Thank you so very much for your prompt and informative reply. > valueDef = Forward() > valueDef << ( key + EQ + LT + ZeroOrMore( Group(valueDef | quotedString )) + > GT ) I am certain that my problem is that I still do not have a good grasp of Forward(). Is this the meaning of the valueDef assignment? "valueDefs are composed of a key followed by an = followed by < and then zero or more embedded valueDefs or quoted strings. The key is composed of an attribute name or a bracketed and quoted string" BTW: The example you sent raises ParseException; pyparsing.ParseException: Expected ">" (at char 55), (line:4, col:17) Thanks. Tim -- Timothy Cook, MSc Health Informatics Research & Development Services http://timothywayne.cook.googlepages.com/home 01-904-322-8582 |