Recent Changes

Monday, January 2

  1. page GettingHelp edited ... You can also browse that page for previous posts. Pyparsing mailing list on SourceForge ...…
    ...
    You can also browse that page for previous posts.
    Pyparsing mailing list on SourceForge
    ...
    message to pyparsing(a)lists.sourceforge.net.pyparsing-users(a)lists.sourceforge.net. To subscribe/unsubscribe
    SourceForge Help/Discussion Forum
    You can post questions and comments on the Help/Discussion forum of the pyparsing project area on SourceForge.
    (view changes)
    5:04 am

Friday, December 30

  1. 8:05 am
  2. msg Forward() anc recursion error message posted Forward() anc recursion error Glad you found your error. Pyparsing includes many helper methods. A common pattern is to parse …
    Forward() anc recursion error
    Glad you found your error.

    Pyparsing includes many helper methods. A common pattern is to parse comma-delimited lists, using "expr + ZeroOrMore(',' + expr)". pyparsing has a method that allows you to replace this with "delimitedList(expr)". The delimiters themselves are removed from the parsed tokens, and delimiters other than ',' can be named using "delimitedList(expr, delim='|')" (if using a '|' for delimiter, for instance). If items are just delimited by whitespace, then you can just use "OneOrMore(expr)", since pyparsing implicitly skips over whitespace.

    Welcome to pyparsing!

    -- Paul
    8:02 am
  3. msg Forward() anc recursion error message posted Forward() anc recursion error I've found the error! I should use p1=Literal("(") p2=Literal(")") v=L…
    Forward() anc recursion error
    I've found the error!
    I should use
    p1=Literal("(")
    p2=Literal(")")
    v=Literal(",")
    4:56 am

Thursday, December 29

  1. msg Forward() anc recursion error message posted Forward() anc recursion error Hello all, i'm trying to understand how to use forward with this simple example: variable= Word(…
    Forward() anc recursion error
    Hello all, i'm trying to understand how to use forward with this simple example:

    variable= Word(alphanums)
    p1=Word("(")
    p2=Word(")")
    v=Word(",")
    name=Word(alphanums)
    funct=Forward()
    arg=funct|argFunct
    funct << (name+p1+arg+ZeroOrMore(v+arg)+p2)

    But this code doesnt work when i try to parse strings like "a(a(a))"
    Can you help me?
    Thank you
    8:57 pm

Wednesday, December 14

  1. 6:28 pm

Thursday, December 8

  1. msg Can't get the simplest expression to work message posted Can't get the simplest expression to work "[identifier uint64 19023789]" does not match your expression for attribute.
    Can't get the simplest expression to work
    "[identifier uint64 19023789]" does not match your expression for attribute.
    8:21 pm
  2. msg Can't get the simplest expression to work message posted Can't get the simplest expression to work Thanks, that was awesome! Now I have a more complicated parser, but for the life of me can't figure…
    Can't get the simplest expression to work
    Thanks, that was awesome! Now I have a more complicated parser, but for the life of me can't figure why it won't accept more than one input! I'm using the OneOrMore to accept multiple 'proto' definitions in one protofile, but it gives me a parser error: pyparsing.ParseException: Expected end of text.

    Parser definition:
        attribute = pp.Group(pp.Suppress('[') + pp.OneOrMore(pp.Word(pp.alphas)) + pp.Suppress(']'))
        member = pp.Group(pp.Word(pp.printables) + pp.Word(pp.printables.replace(';', '')) + pp.Suppress(';'))
     
        msgHeader = pp.ZeroOrMore(attribute)
        msgName = pp.Word(pp.printables)
        msgContent = pp.Suppress('{') + pp.OneOrMore(member) + pp.Suppress('}')
     
        msgWithContent = pp.Keyword("message").suppress() + msgName + msgContent
        defaultMsg = pp.Keyword("default").suppress() + pp.Suppress(';')
     
        protoStatement = msgHeader + pp.MatchFirst([msgWithContent, defaultMsg])
        protoFileParser = pp.ZeroOrMore(protoStatement)
     
        protoFileParser.parseString(fileContents, parseAll=True)

    Test file:
    [endianness network]
    [namespace protoOne]
    message JumpPacket {
        uint64 PlayerID;
    }
     
    [identifier uint64 19023789]
    [endianness network]
    [namespace protoOne]
    message MovementPacket {
        uint16    X;
        uint16    Y;
     
        uint64 PlayerID;
        string Msg;
    }
    7:08 pm

Wednesday, December 7

  1. 8:10 pm
  2. msg Can't get the simplest expression to work message posted Can't get the simplest expression to work One thing that is important about pyparsing is that, unlike regex, you focus on the parts of the in…
    Can't get the simplest expression to work
    One thing that is important about pyparsing is that, unlike regex, you focus on the parts of the input that *aren't* whitespace. So to use pyparsing to parse a list of words delimited by spaces isn't really consistent with pyparsing philosophy. Instead, you would use "OneOrMore(Word(alphas))" - pyparsing skips over whitespace implicitly. Please look over the examples on the Examples wiki page, to see various approaches to parsing lists, command syntax, etc. Welcome to pyparsing! -- Paul
    7:49 pm

More