parsers / lexers usable from Python and Java (and C++/C)?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John J. Lee

    parsers / lexers usable from Python and Java (and C++/C)?

    Are there any parser / lexer generators useable from both CPython and
    Java? I don't mind much if the Python-useable output is in Python or
    C (as long as the C can be wrapped automatically, of course). If I
    could run the same source files through two different tools, that
    would be just as good.

    I'm aware that I could use ANTLR from Jython or perhaps Python+JPE,
    but I was looking for something accessible from CPython without having
    Java installed, too (speed, and ease of use direct from C++ and C
    would be a bonus). And no, I don't want to use JNI!

    Failing that, do tools exist for which one could write spec. files for
    lexer / parser generators that produce code useable from CPython, and
    then apply some minimal tweaks and run them through another tool(s)
    that generates Java code? YAPPS for Python and ANTLR for Java,
    perhaps -- anybody tried that?


    John
  • John J. Lee

    #2
    Re: parsers / lexers usable from Python and Java (and C++/C)?

    "Mike Rovner" <mike@nospam.co m> writes:
    [color=blue]
    > John J. Lee wrote:[color=green]
    > > Are there any parser / lexer generators useable from both CPython and
    > > Java?[/color]
    >
    > PLY (http://systems.cs.uchicago.edu/ply/) implemented entirely in Python,
    > so it might be possible to use it from both implementations of Python.[/color]

    No, I really did mean CPython and Java, not CPython and Jython.

    [color=blue]
    > You may look at http://www.python.org/cgi-bin/moinmoin/LanguageParsing for
    > other tools.[/color]

    Thanks. There doesn't seem to be anything promising there,
    unfortunately.

    All I've found so far are some threads in which Tim Peters complains
    about the lack of a Python interface of some kind to lex. Maybe I can
    automatically SWIG-wrap lex's lexers, and use jflex for Java. For
    parsing (and maybe lexing too), *maybe* it's possible to auto-wrap the
    C++ ANTLR outputs, but wrapping C++ (even generated C++) in an
    automated way without pain seems unlikely.


    John

    Comment

    • Mike Rovner

      #3
      Re: parsers / lexers usable from Python and Java (and C++/C)?

      John J. Lee wrote:[color=blue]
      > "Mike Rovner" <mike@nospam.co m> writes:
      >[color=green]
      >> John J. Lee wrote:[color=darkred]
      >>> Are there any parser / lexer generators useable from both CPython
      >>> and Java?[/color]
      >>
      >> PLY (http://systems.cs.uchicago.edu/ply/) implemented entirely in
      >> Python, so it might be possible to use it from both implementations
      >> of Python.[/color]
      >
      > No, I really did mean CPython and Java, not CPython and Jython.[/color]

      Your goal is a little vague for me. Jython IS java.
      [color=blue]
      > ... wrapping C++ (even generated C++) in an
      > automated way without pain seems unlikely.[/color]

      Take a look at boost.python pyste.

      Mike




      Comment

      • John J. Lee

        #4
        Re: parsers / lexers usable from Python and Java (and C++/C)?

        "Mike Rovner" <mike@nospam.co m> writes:
        [...][color=blue][color=green][color=darkred]
        > >> PLY (http://systems.cs.uchicago.edu/ply/) implemented entirely in
        > >> Python, so it might be possible to use it from both implementations
        > >> of Python.[/color]
        > >
        > > No, I really did mean CPython and Java, not CPython and Jython.[/color]
        >
        > Your goal is a little vague for me. Jython IS java.[/color]

        Oh, you anal hacker, you.

        [color=blue][color=green]
        > > ... wrapping C++ (even generated C++) in an
        > > automated way without pain seems unlikely.[/color]
        >
        > Take a look at boost.python pyste.[/color]

        Cool! There are so many nice cross-language tools out there for
        Python now... :-)

        Thanks


        John

        Comment

        Working...