Recent Changes

Saturday, September 17

  1. msg Bugreport: setParseAction for quotedString sets a global parse action message posted Bugreport: setParseAction for quotedString sets a global parse action If you want specialized behavior for an expression (whether one of the helpers provided by pyparsin…
    Bugreport: setParseAction for quotedString sets a global parse action
    If you want specialized behavior for an expression (whether one of the helpers provided by pyparsing, like quotedString, or one you create yourself), make a copy using expr.copy() or just expr(). Then you can add parse actions to the copy, and the original will be unaffected.
    6:58 am
  2. msg Performance with parsing braces message posted Performance with parsing braces Documentation for packrat parsing is here: https://pythonhosted.org/pyparsing/pyparsing.ParserEle…
    Performance with parsing braces
    Documentation for packrat parsing is here: https://pythonhosted.org/pyparsing/pyparsing.ParserElement-class.html#enablePackrat
    6:54 am
  3. msg Performance with parsing braces message posted Performance with parsing braces Enable packrat parsing, to get infixNotation to use an internal cache for speeding up parsing. (Sor…
    Performance with parsing braces
    Enable packrat parsing, to get infixNotation to use an internal cache for speeding up parsing. (Sorry to be slow in responding, I do not check this discussion page very often.)
    6:52 am

Tuesday, September 6

Wednesday, May 11

  1. msg Enhancement/bugfix to fourFn.py message posted Enhancement/bugfix to fourFn.py I am getting an error for python 3.4 with the latest release. After installing, when trying to impo…
    Enhancement/bugfix to fourFn.py
    I am getting an error for python 3.4 with the latest release. After installing, when trying to import pyparsing I get


    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/.virtualenvs/test/lib/python3.4/site-packages/pyparsing.py", line 3478, in <module>
    _escapedPunc = Word( _bslash, r"\[]-*.$+^?()~ ", exact=2 ).setParseAction(lambda s,l,t:t[0][1])
    File "/.virtualenvs/test/lib/python3.4/site-packages/pyparsing.py", line 948, in setParseAction
    self.parseAction = list(map(_trim_arity, list(fns)))
    File "/.virtualenvs/test/lib/python3.4/site-packages/pyparsing.py", line 808, in _trim_arity
    this_line = extract_stack()[-1]
    File "/.virtualenvs/test/lib/python3.4/site-packages/pyparsing.py", line 793, in extract_stack
    return [(frame_summary.filename, frame_summary.lineno)]
    AttributeError: 'tuple' object has no attribute 'filename'
    2:47 am

Monday, March 21

  1. msg Performance with parsing braces message posted Performance with parsing braces Hi, I have done simple parser of logical expressions by example and add operators <,>, =, et…
    Performance with parsing braces
    Hi,
    I have done simple parser of logical expressions by example and add operators <,>, =, etc. (infixNotation). It's good but parsing of a string vary from 0.2 to 2 s. I read about associating parse actions with the concret tokens and will try it. Now solve that by caching parse results )
    But it's does not a problema. My problem is that when there are braces in expression, parsing time icrease till 20 secondds!
    E.g.: ({a.b} < 1or {a.d} = 2) and k in [1, 2, 3] - '{}' is my quoted string and i have no problem with it if there no braces in expression. I have not wrote any special token definitions to parse the braces and need in advice how to improve infix parser to do with.

    P.S. Calculation of result on parsed expression is very fast!
    12:29 pm

Tuesday, March 15

  1. msg Bugreport: setParseAction for quotedString sets a global parse action message posted Bugreport: setParseAction for quotedString sets a global parse action Hi, If I set the parse action for any quotedString, the parse action for all quotedStrings is re…
    Bugreport: setParseAction for quotedString sets a global parse action
    Hi,

    If I set the parse action for any quotedString, the parse action for all quotedStrings is replaced. I haven't expected this behavior.

    Example:

        • import pyparsing as pp
        • parser = pp.delimitedList(
    ... pp.quotedString | pp.SkipTo(pp.White() | pp.LineEnd()),
    ... delim = pp.White()
    ... )
    ...
        • parser.parseString('-comment "foo: "')
    (['-comment', '"foo: "'], {})
        • x = pp.quotedString.setParseAction(pp.removeQuotes)
        • x.parseString("'foo'")
    (['foo'], {})
        • parser.parseString('-comment "foo: "')
    (['-comment', 'foo: '], {})

    Workaround:
    If you set the parse action of quotedString to function, which does nothing, you can avoid this problem

        • x = pp.quotedString.setParseAction(lambda : None)
        • parser.parseString('-comment "reise_fl: "')
    (['-comment', '"reise_fl: "'], {})
    7:06 am

More