Donate Share

Python parsing module

Code

Programming Languages: Python

License: MIT License

Repositories

browse code, statistics, last commit on 2009-09-24 svn co https://pyparsing.svn.sourceforge.net/svnroot/pyparsing pyparsing

Show:

What's happening?

  • Comment: SkipTo ignore print statement

    Thanks for the bug report - this will be removed in the next release.

    2009-12-23 18:24:23 UTC by ptmcg

  • Comment: would like setParseAction to yield a None on my token stream

    I sent a working solution back in a comment on the request, but no response from the requestor.

    2009-12-23 18:21:41 UTC by ptmcg

  • Followup: RE: using ignore without supressing the output

    Tal - When I've had people in the past try to keep track of the start/stop locations of a particular match, I usually start with having them use scanString, which exposes these values directly. In cases where they really want to include start and stop locations in their code, then I recommend something like this: parseLocn = lambda s,locn,t : locn locnExpr =...

    2009-12-23 18:16:58 UTC by ptmcg

  • Followup: RE: Hierarchy Tree Within ParseResults?

    Leon - By default, pyparsing elevates all results names to a flat namespace, since there is no telling how many intermediate levels there might be included artificially due to the assembly of the parser from its different parts. But you can introduce a sort of namespace to the results names, by using the Group class: fruit = Group(OneOrMore(a | b)).setResultsName("fruit") veg...

    2009-12-23 18:06:28 UTC by ptmcg

  • Followup: RE: using ignore without supressing the output

    Answering myself again: iterating over all of my expressions did not work and it still involved a lot of messing with pyparsing internals... Here is my current approach (and it is non-invasive!): I add a parseAction that uses the (original_string, loc, tokens) input. Instead of simply joining the tokens, I look at original_string[loc] and see if there are spaces around it. If so, I add...

    2009-12-12 08:17:53 UTC by majortal

  • Followup: RE: using ignore without supressing the output

    hmmm... but you did get me thinking. I can iterate over the expressions in my rule. It is always an AND. So I can theoretically implement the functionality of AND myself using scanString. Not fun, but will this work?.

    2009-12-09 20:02:23 UTC by majortal

  • Followup: RE: using ignore without supressing the output

    Hi Paul, __Thanks for the fast reply!__ Yes, I am using parseString, but that is the behavior I am looking for. I'm trying to match complex expressions, such as: e1 + e2 + (e3^e4) + Optional(e5) + (e6|e7|e8) + stringEnd The atomic expressions are __usually__ Regex, but I also use a few Literals, SkipTo, Empty, Word and ZeroOrMore... I often add setParseAction to control the...

    2009-12-09 19:40:03 UTC by majortal

  • Followup: RE: using ignore without supressing the output

    Tal - Hrmmm, you are really messing with some core pyparsing behavior. I'm not sure just what you are trying to do with this program. I'm wondering if you are using parseString for your program, but might actually be better off using scanString. If you use scanString, you won't have to do so much unnatural work to keep the whitespace and comments (unnatural to pyparsing, anyway), but the...

    2009-12-09 12:58:29 UTC by ptmcg

  • Followup: RE: using ignore without supressing the output

    and another related question: is there a way to still skip whitespace (which is a good thing) but get it back as a token (part of the result)? I want my grammar to skip spaces but maintain for example the fact the there were 3 spaces and not 1. The only option I see now is to apply leaveWhitespace() and to add white space to the ignorables (after my patch). Which is kinda ugly. Is there...

    2009-12-09 12:42:04 UTC by majortal

  • Followup: RE: using ignore without supressing the output

    I started modifying the behavior of ParserElement._skipIgnorables() I made it return the tokens. also had to change ParserElement.preParse() (to return the tokens as well. Then in ParserElement._parseNoCache() I aggregated the results. Also changed ParserElement.ignore() to NOT force the casting into Suppress. Which kind of worked.... a. it looks very inefficient...

    2009-12-09 12:17:24 UTC by majortal

Our Numbers