[antlr-interest] Invalid class cast exception DebugTokenStream/TokenRewriteStream when rewriting C source
Aggelos Biboudis
biboudis at gmail.com
Fri Sep 28 07:02:50 PDT 2012
Dear all,
I am using the debug feature of ANTLRWorks 1.4.3 to make source-to-source
transformations of a C program. I have altered the grammar rule for
compound statement with the following format:
compound_statement
: '{' {<some_semantic_predicate>}? declaration* statement_list? '}' ->
<some_alternative>
| '{' declaration* statement_list? '}'
;
I am getting a ClassCastException in runtime for these two class types.
Exception in thread "main" java.lang.ClassCastException:
org.antlr.runtime.debug.DebugTokenStream cannot be cast to
org.antlr.runtime.TokenRewriteStream
at CParser.compound_statement(CParser.java:10615)
at CParser.statement(CParser.java:9444)
at CParser.selection_statement(CParser.java:11022)
at CParser.statement(CParser.java:9472)
at CParser.statement_list(CParser.java:10796)
at CParser.compound_statement(CParser.java:10693)
at CParser.function_definition(CParser.java:1171)
at CParser.external_declaration(CParser.java:778)
at CParser.translation_unit(CParser.java:379)
at __Test__.main(__Test__.java:19)
In CParser, line 10615, contains only an integer assignment, so I cannot
understand what may went wrong. Has anyone any clue about what may have
happened here?
Thanks,
Aggelos
More information about the antlr-interest
mailing list