which parser to use

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • a_nuther@geek.org

    #1

    which parser to use


    I'm building something that requires parsing a rather complex
    language. I'd like to do the whole application, including the
    lex/parse phase, in Python (for development/debug speed), and only
    move parts of it to a compiled language if execution speed absolutely
    dictates. So, what i'm looking for in a Python parser is:

    1) reliability (don't want to debug a parser)
    1) flexibility (i do a lot of refactoring)
    2) E/BNF friendliness (working from a spec)
    3) speed (moderate speed will do; glacial won't)

    Does anyone have any familiarity with some of the several Python
    parsers out there? Any pointers to comparisons (as opposed to surveys)
    of _several_ of the Python parsers would be much appereciated. (I've
    seen the YAPPS/Spark comparison.) If none of the Python parsers really
    fit the bill, any thoughts on ANTLR, Spirit, etc?

    Thanks in advance,
    E

  • Jean Brouwers

    #2
    Re: which parser to use


    Check out SimpleParse/mxTextTools. Just an outstanding E/BNF driven
    parser, very highly recommended.

    <http://simpleparse.sou rceforge.net/>

    /Jean Brouwers

    PS) See also

    <http://www-128.ibm.com/developerworks/linux/library/l-simple.html>

    <http://gnosis.cx/publish/programming/charming_python _b4.html>

    There are descriptions of other Python-based parsers on this site
    <http://gnosis.cx/TPiP/>



    In article <87ll9hmdd6.fsf @subopt.house-net>, <a_nuther@geek. org> wrote:
    [color=blue]
    > I'm building something that requires parsing a rather complex
    > language. I'd like to do the whole application, including the
    > lex/parse phase, in Python (for development/debug speed), and only
    > move parts of it to a compiled language if execution speed absolutely
    > dictates. So, what i'm looking for in a Python parser is:
    >
    > 1) reliability (don't want to debug a parser)
    > 1) flexibility (i do a lot of refactoring)
    > 2) E/BNF friendliness (working from a spec)
    > 3) speed (moderate speed will do; glacial won't)
    >
    > Does anyone have any familiarity with some of the several Python
    > parsers out there? Any pointers to comparisons (as opposed to surveys)
    > of _several_ of the Python parsers would be much appereciated. (I've
    > seen the YAPPS/Spark comparison.) If none of the Python parsers really
    > fit the bill, any thoughts on ANTLR, Spirit, etc?
    >
    > Thanks in advance,
    > E
    >[/color]

    Comment

    • Miki Tebeka

      #3
      Re: which parser to use

      Hello E,
      [color=blue]
      > I'm building something that requires parsing a rather complex
      > language. I'd like to do the whole application, including the
      > lex/parse phase, in Python (for development/debug speed), and only
      > move parts of it to a compiled language if execution speed absolutely
      > dictates. So, what i'm looking for in a Python parser is:
      >
      > 1) reliability (don't want to debug a parser)
      > 1) flexibility (i do a lot of refactoring)
      > 2) E/BNF friendliness (working from a spec)
      > 3) speed (moderate speed will do; glacial won't)
      >
      > Does anyone have any familiarity with some of the several Python
      > parsers out there? Any pointers to comparisons (as opposed to surveys)
      > of _several_ of the Python parsers would be much appereciated. (I've
      > seen the YAPPS/Spark comparison.) If none of the Python parsers really
      > fit the bill, any thoughts on ANTLR, Spirit, etc?[/color]
      I'm very happy with PLY (http://systems.cs.uchicago.edu/ply/).
      I was used in several small parsers here and it's easy to maintain, works
      in acceptable speed and IMO the code is very readable.
      Also I find the documentation very good.

      HTH.
      --
      ------------------------------------------------------------------------
      Miki Tebeka <miki.tebeka@zo ran.com>

      The only difference between children and adults is the price of the toys

      Comment

      • Paul McGuire

        #4
        Re: which parser to use

        a_nuther@geek.o rg wrote:[color=blue]
        > I'm building something that requires parsing a rather complex
        > language. I'd like to do the whole application, including the
        > lex/parse phase, in Python (for development/debug speed), and only
        > move parts of it to a compiled language if execution speed absolutely
        > dictates. So, what i'm looking for in a Python parser is:
        >
        > 1) reliability (don't want to debug a parser)
        > 1) flexibility (i do a lot of refactoring)
        > 2) E/BNF friendliness (working from a spec)
        > 3) speed (moderate speed will do; glacial won't)
        >
        > Does anyone have any familiarity with some of the several Python
        > parsers out there? Any pointers to comparisons (as opposed to[/color]
        surveys)[color=blue]
        > of _several_ of the Python parsers would be much appereciated. (I've
        > seen the YAPPS/Spark comparison.) If none of the Python parsers[/color]
        really[color=blue]
        > fit the bill, any thoughts on ANTLR, Spirit, etc?
        >
        > Thanks in advance,
        > E[/color]

        Depending on just *how* complex your EBNF is, pyparsing may be
        suitable. It has been used for Verilog, DOT, TeX, and agent language
        parsing. Pyparsing is a "combinator ", in which you assemble the
        grammar using expression objects such as Literal, Word, OneOrMore,
        etc., all in pure Python code - no separate lex/yacc syntax, or code
        generation/synchronization steps. It *may* be somewhat slow for your
        purposes, but I find the grammars to be readable and easily maintained
        and extended.

        Download pyparsing at http://pyparsing.sourceforge.net.

        -- Paul

        Comment

        Working...