Re: [Pyparsing] To parse any language character set
Brought to you by:
ptmcg
From: Ujjaval S. <usm...@gm...> - 2008-11-03 01:05:23
|
Hi Eike, Thanks for that. Actually, the reason my grammer was not working is because I had to put \r inside CharsNotIn() where I only had '|'. The did the trick for me. Cheers, On Thu, Oct 30, 2008 at 3:17 AM, Eike Welk <eik...@gm...> wrote: > Hello Ujjaval! > > On Tuesday 28 October 2008, you wrote: > > Now to parse such sentence, I changed your parser code to the > > following: Here, I want to parse this string as a string that > > starts with 'ABC' followed by '|' and ends with '\r'. I need > > everything in between with '|' as delimiter in a list including > > 'XYZ' as last element in this case. > > Look at: > LineEnd() > > Your parsers normally don't see '\n' because the whitespace is removed > by the parsing machinery. If you want to use the end-of-line > frequently as an element in your grammar, you could tell Pyparsing > that '\n' should not be treated as whitespace: > ParserElement.setDefaultWhitespaceChars('\t ') > > But you have to care for all the newlines youself then, which might > become tedious. Look at > indentedBlock(...) > as an example how Paul (Pyparsing's author) does it. (I use > indentedBlock myself.) > > Kind regards, > Eike. > > |