Forum Stats

  • 3,851,952 Users
  • 2,264,054 Discussions
  • 7,904,914 Comments

Discussions

Announcing: CUP grammar for JSR-14

843793
843793 Member Posts: 41,732 Green Ribbon
edited Apr 24, 2003 11:03AM in Generics
I have posted a grammar for the language defined by JSR-14 at http://www.cs.princeton.edu/~appel/modern/java/CUP/

It is an LALR(1) grammar for the CUP Java parser generator; it handles type casts to parameterized types using a "smart lexer" technique to work around the fact that the JSR-14 grammar is not really LALR(1). I'm told that this grammar is pretty straightforward to implement in a LL(k) parser generation tool like ANTLR.

Anyway, it's there and it works, as far as I can tell from all the source code I've piped through it. Use it, and if you find any valid JSR-14 programs which is does not correctly parse, please let me know (you can use the bug report address for CUP at the URL above). Share & enjoy...

Comments

  • 843793
    843793 Member Posts: 41,732 Green Ribbon
    It is an LALR(1) grammar for the CUP Java parser
    generator; it handles type casts to parameterized
    types using a "smart lexer" technique to work around
    the fact that the JSR-14 grammar is not really
    LALR(1). I'm told that this grammar is pretty
    straightforward to implement in a LL(k) parser
    generation tool like ANTLR.
    Neat! So, I've read that the Java language can be represented in an LALR(2) grammar, which CUP is capable of handling. Does the Generic Java functionality affect the LALR(2) status of the language?
  • 843793
    843793 Member Posts: 41,732 Green Ribbon
    By the way, do you work on the CUP project? I use it for my programming language "Frink," and I like it a lot, but I'm always kind of worried that no releases have been made of the parser for years. I'm especially curious if there's a fix for the "Precedence Misfeature" reported by S.M. Kahrs on the bugs page:

    http://www.cs.princeton.edu/~appel/modern/java/CUP/bugs.html

    This has bit me a few times. Thanks!

    http://futureboy.homeip.net/frinkdocs/

  • 843793
    843793 Member Posts: 41,732 Green Ribbon
    Just a note that I've recently (Apr 13, 2003) updated this grammar to fix some bugs conforming to (Sun's reading of) the JLS-2 standard and in parsing nested parameterized types. The update is in response to some very useful bug reports & fixes by Eric Blake of the Jikes project. Thanks, Eric!
This discussion has been closed.