Re: [Pyparsing] setParseAction()
Brought to you by:
ptmcg
From: Andreas M. <and...@gm...> - 2014-08-29 15:20:25
|
Athanasios Anastasiou wrote: > 1) Do you really need your parsed string to be enclosed in three single > quotes? Actually I'm parsing a file with parseFile(). > 2) The error you are getting is reasonable. The rule p expects to start at > the beginning of the parsed string. Be defining g as 'b'+p, you are placing > rule p AFTER the beginning of the line (which is where the character 'b' > will be). But the string consists of 3 line and for the second line I created a parser with LineStart() and LineEnd(). That's why I'm using LineStart() to get the beginning of the second line. Is this wrong? What puzzles me is that the parser yields the correct results, as long as no actions are attached to it. At least it's the result I expected. But after adding setParseAction() it is no longer working. Maybe I should explain my original case: I try to parse a file which has /one/ particular line containing a few numbers separated by spaces. I do not know how many numbers there are in this line. I just know that they are in this particular line. Thus I need to take care about linebreak in this line. For the rest of the file (before and after this line) I do not need to (and don't want to) take care about linebreaks. Ciao Andreas |