Re: [Pyparsing] Why are ignore settings not applied in Combine statement ?
Brought to you by:
ptmcg
From: Ralph C. <ra...@in...> - 2008-01-16 13:46:04
|
Hi Samuel, > from pyparsing import Literal, Combine > grammar = Combine(Literal("A") + Literal("B") + Literal("C")) > grammar.ignore(",") > grammar.parseString("A,,,,,B,,C") > > ...but I suddently got a ParseException: > pyparsing.ParseException: Expected "B" (at char 1), (line:1, col:2) > > It seems that the commas are not anymore ignored in the Combine > statement! Can anyone tell me why, or how to have the parser apply > ignore rules also in the Combine command ? You need to get the commas ignored before attempting to combine. >>> from pyparsing import Literal, Combine >>> grammar = Literal("A") + Literal("B") + Literal("C") >>> grammar.ignore(",") >>> grammar = Combine(grammar) >>> grammar.parseString("A,,,,,B,,C") (['ABC'], {}) >>> Cheers, Ralph. |