Loading ...
Sorry, an error occurred while loading the content.

ClassCastExceptions extending CommonAST

Expand Messages
  • inyoursadmachine
    Hi, I m brand new to ANTLR and this mailing list. I m using ANTLR to write an emulator for a C-like language but getting ClassCastExceptions when using
    Message 1 of 2 , Dec 13, 2004
    • 0 Attachment
      Hi,
      I'm brand new to ANTLR and this mailing list. I'm using ANTLR to
      write an emulator for a C-like language but
      getting 'ClassCastExceptions' when using extension of CommonAST. At
      first I thought it was me but when I ran in to the -exact- same
      problem with the 'Pascal' example I thought I'd ask here.


      I'm using ANTLR 2.7.4 and Java version is 1.5

      C:\>java -version
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


      C:\Program Files\ANTLR\antlr-2.7.4\examples\java\pascal>java
      PascalParser big.pas
      Parsing...
      C:\Program Files\ANTLR\antlr-2.7.4\examples\java\pascal\big.pas
      Can't find/access AST Node typePascalAST
      parser exception: java.lang.ClassCastException: antlr.CommonAST
      java.lang.ClassCastException: antlr.CommonAST
      at PascalParser.programHeading(PascalParser.java:261)
      at PascalParser.program(PascalParser.java:201)
      at PascalParser.parseFile(PascalParser.java:79)
      at PascalParser.doFile(PascalParser.java:57)
      at PascalParser.main(PascalParser.java:151)


      Is this a known problem? Is 2.7.4 considered "stable" ? Should I
      use/try an earlier version?

      Thanks in advance,
      Matt
    • Terence Parr
      ... Hi. :) The error should help out I think. Seems it s trying to create those node types, but can t. Look for the invocation of the parser and see if it
      Message 2 of 2 , Dec 13, 2004
      • 0 Attachment
        On Dec 13, 2004, at 9:27 PM, inyoursadmachine wrote:
        > Hi,
        > I'm brand new to ANTLR and this mailing list. I'm using ANTLR to
        > write an emulator for a C-like language but
        > getting 'ClassCastExceptions' when using extension of CommonAST. At
        > first I thought it was me but when I ran in to the -exact- same
        > problem with the 'Pascal' example I thought I'd ask here.
        >
        >
        > I'm using ANTLR 2.7.4 and Java version is 1.5
        >
        > C:\>java -version
        > java version "1.5.0"
        > Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
        > Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
        >
        >
        > C:\Program Files\ANTLR\antlr-2.7.4\examples\java\pascal>java
        > PascalParser big.pas
        > Parsing...
        > C:\Program Files\ANTLR\antlr-2.7.4\examples\java\pascal\big.pas
        > Can't find/access AST Node typePascalAST

        Hi. :) The error should help out I think. Seems it's trying to create
        those node types, but can't. Look for the invocation of the parser and
        see if it is setting the node type. You might also look at the
        ASTLabel option in the grammar to see if that's set. Is
        typePascalAST.java around in the CLASSPATH?

        Ter
      Your message has been successfully submitted and would be delivered to recipients shortly.