Recent Changes

Friday, March 4

  1. msg Infinite loop when removing malformed cpp style comments message posted Infinite loop when removing malformed cpp style comments s = '/** lots of *'s'
    Infinite loop when removing malformed cpp style comments
    s = '/** lots of *'s'
    9:03 am
  2. msg Infinite loop when removing malformed cpp style comments message posted Infinite loop when removing malformed cpp style comments Tested on ubuntu with version 2.0.1 from pyparsing import cppStyleComment import pyparsing s =…
    Infinite loop when removing malformed cpp style comments
    Tested on ubuntu with version 2.0.1

    from pyparsing import cppStyleComment
    import pyparsing
    s = '/*' #malformed missing trailing slash
    cppStyleComment.suppress().transformString(s)
    print("never gets this far, just sits there using 100% CPU")
    9:03 am

Wednesday, March 2

  1. msg Enhancement/bugfix to fourFn.py message posted Enhancement/bugfix to fourFn.py I advise you to stop using Sourceforge for distributing pyparsing. See for example the following li…
    Enhancement/bugfix to fourFn.py
    I advise you to stop using Sourceforge for distributing pyparsing. See for example the following link:
    http://arstechnica.com/information-technology/2015/05/sourceforge-grabs-gimp-for-windows-account-wraps-installer-in-bundle-pushing-adware/
    2:50 pm

Monday, February 22

  1. msg The ParseExcetion issue in <<IndentGrammer.py>> message posted The ParseExcetion issue in <<IndentGrammer.py>> ParseExceptions are the core mechanism for pyparsing's implementation of success/failure testing wh…
    The ParseExcetion issue in <<IndentGrammer.py>>
    ParseExceptions are the core mechanism for pyparsing's implementation of success/failure testing when executing a parser. Often the exceptions *are* trapped as part of the parsing process. For instance in this case:

    A = Literal("A")
    B = Literal("B")
    C = Literal("C")
     
    (A | B | C).parseString("C")

    In the implementation of the MatchFirst class, every alternative is tested in turn until a successful parse is found. Internally, the expressions for A and B *do* raise exceptions, but these are caught by the MatchFirst class. Only if all the alternatives are tested and fail will MatchFirst raise its own exception.

    When exceptions are raised when not really wanted, then you have to look at your parser design to see how things are set up, or whether the input string contains some surprising input. If we got an unwanted exception from this statement:

    # surprise! it's a lower-case 'c'
    (A | B | C).parseString("c")

    then we would have to consider whether the input was improperly formatted (such as failing to call *upper()* before passing the string to be parsed), or if the parser could be made more robust by using CaselessLiteral instead of Literal.

    Indented grammars are not the most popular with pyparsing; they rely heavily on column testing and maintaining the indentation stack outside the parser itself. If you are getting unwanted errors on the indentation, you may be dealing with data that has embedded tabs - if so, an indentation-based parser will have some difficulty. I would definitely advise against calling parseWithTabs() with an indentation parser, as pyparsing's column algorithm does not try to compute the various possible space counts that <TAB> characters can maintain - they are treated as simply single characters.

    Other than those generic comments, though, it is hard to be more specific without seeing more of your grammar, and some sample text that demonstrates the problem. Also, this wiki does not get that much traffic or attention - you would do better posting questions on the pyparsing (not pyparsing-public) wiki home page discussion, or on StackOverflow.
    9:03 pm
  2. 8:52 pm
  3. msg The ParseExcetion issue in <<IndentGrammer.py>> message posted The ParseExcetion issue in <<IndentGrammer.py>> so far as I understand, raise ParseException(s,l,"not a peer entry") is critical to impl…
    The ParseExcetion issue in <<IndentGrammer.py>>
    so far as I understand, raise ParseException(s,l,"not a peer entry") is critical to implement INDENT

    but why the exception can't be trapped sometime? is there some implication rules?
    6:44 pm

Sunday, August 23

  1. 7:46 pm

More