[antlr-interest] Any clue for this internal error?

Meng Tian tomnebula at gmail.com
Tue Aug 28 07:50:14 PDT 2012


Ah, I see. Yes, you are right. There is no complaining after I add a parser
rule as you suggested.

Thank you.

On Tue, Aug 28, 2012 at 3:44 PM, Kirby Bohling <kirby.bohling at gmail.com>wrote:

> That sure looks like you don't have a parser rule, only lexer rules.  I
> believe this would work, but I don't have ANTLR handy to actually try it.
>
> =======================================
> grammar CL;
>
>
>     INPUTS : 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
>     OUTPUTS : 'U' | 'V' | 'X' | 'Y' | 'Z';
>
>     INPUT : 'i';
>     OUTPUT : 'o';
>
>     action: ( INPUT INPUTS ) | ( OUTPUT OUTPUTS );
> =======================================
>
> Kirby
>
>
> On Tue, Aug 28, 2012 at 8:43 AM, Meng Tian <tomnebula at gmail.com> wrote:
>
>> Hello
>>
>> I am new to ANTLR, and I try to start with a very simple grammar
>> definition
>> (as follows).
>>
>> =======================================
>> grammar CL;
>>
>>     fragment INPUTS : 'A' | 'B' | 'C' | 'D' | 'E' | 'F';
>>     fragment OUTPUTS : 'U' | 'V' | 'X' | 'Y' | 'Z';
>>
>>     fragment INPUT : 'i';
>>     fragment OUTPUT : 'o';
>>
>>     ACTION : ( INPUT INPUTS ) | ( OUTPUT OUTPUTS );
>> =======================================
>>
>> I was expecting that strings like "iA" and "oU" should be successfully
>> recognized and given the "ACTION" token. But when I run "java
>> org.antlr.Tool CL.g", I had the following error message:
>>
>> =======================================
>> error(10):  internal error: CL.g : java.lang.ClassCastException:
>> org.antlr.runtime.tree.CommonTree cannot be cast to
>> org.antlr.tool.GrammarAST
>> org.antlr.grammar.v3.CodeGenTreeWalker.rules(CodeGenTreeWalker.java:1467)
>>
>> org.antlr.grammar.v3.CodeGenTreeWalker.grammarSpec(CodeGenTreeWalker.java:1441)
>>
>> org.antlr.grammar.v3.CodeGenTreeWalker.grammar_(CodeGenTreeWalker.java:509)
>> org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:421)
>> org.antlr.Tool.generateRecognizer(Tool.java:655)
>> org.antlr.Tool.process(Tool.java:468)
>> org.antlr.Tool.main(Tool.java:93)
>> =======================================
>>
>> I have no idea about this error. Any clue on this?
>>
>> Thank you.
>>
>>
>> Regards,
>> Meng
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>


More information about the antlr-interest mailing list