Re: [Pyparsing] Parsing DNS bind file
Brought to you by:
ptmcg
From: <pt...@au...> - 2005-04-28 13:40:41
|
Michele - First of all, are you sure this is a valid entry? The one example file I have would list this as: controls { inet 127.0.0.1 allow { any; }; keys { "key";}; }; instead of your version: controls { inet 127.0.0.1 allow { any; } keys { "key";}; }; Pyparsing includes some debugging capabilities so you can peek into the parsing logic process. Try changing the two lines: simple = Group(value + ZeroOrMore(value) + ";") statement = Group(value + ZeroOrMore(value) + "{" + Optional(toplevel) + "}" + ";") to simple = Group(value + ZeroOrMore(value) + ";").setDebug() statement = Group(value + ZeroOrMore(value) + "{" + Optional(toplevel) + "}" + ";").setDebug() You will now start to see messages during parsing when each of these expressions is tried, and either succeeds or throws an exception. After you get this running, let us know what you find. -- Paul ----- Original Message ----- From: Michele Petrazzo <mic...@un...> Date: Thursday, April 28, 2005 7:32 am Subject: [Pyparsing] Parsing DNS bind file > I want to modify bind parsing example because it don't parse this > data: > controls { > inet 127.0.0.1 allow { any; } keys { "key";}; > }; > > If I remove these three lines, the example work well. > > I add the these two lines to try to parse the new data: > > simple_val = Group(value + '{' + OneOrMore(value + ';') + '}') > only4ctrls = Group('controls' + value + value + > OneOrMore(simple_val) + > "}" + ";") > and modified this: > > toplevel << OneOrMore(simple | statement | only4ctrls) > > but pyparsing stop when it found my new data. Can someone help me? > > Thanks, > Michele > > A complete data can be this: > > key "key" { > algorithm hmac-md5; > secret "abcde1abcde2abcde3abcde4"; > }; > > controls { > inet 127.0.0.1 allow { any; } keys { "key";}; > }; > > options { > pid-file "/var/run/named/named.pid"; > directory "/var/named"; > forwarders { > 62.94.0.1; > 62.94.0.2; > }; > notify no; > }; > > zone "." { > type hint; > file "named.ca"; > }; > > > ------------------------------------------------------- > SF.Net email is sponsored by: Tell us your software development plans! > Take this survey and enter to win a one-year sub to SourceForge.net > Plus IDC's 2005 look-ahead and a copy of this survey > Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix > _______________________________________________ > Pyparsing-users mailing list > Pyp...@li... > https://lists.sourceforge.net/lists/listinfo/pyparsing-users > |