[antlr-interest] DoubleLinkedTree
Alexander Gängel
alexander at gaengel.de
Thu Mar 1 08:07:38 PST 2007
Can anybody give me hint how to get DoublelinkTrees to work?
Alexander Gängel schrieb:
> The exception comes when call the parser.Rule
>
> 19 CharStream input = new ANTLRFileStream(args[0]);
> 20 oclLexer lex = new oclLexer(input);
> 21 CommonTokenStream tokens = new CommonTokenStream(lex);
> 22
> 23 oclParser parser = new oclParser(tokens);
> 24 oclParser.start_return r = parser.start();
>
>
> Exception in thread "main" java.lang.ClassCastException:
> org.antlr.runtime.tree.CommonTree
> at ocl_parser.oclParser.ocl(oclParser.java:186)
> at ocl_parser.oclParser.start(oclParser.java:122)
> at tests.ImBaumsuchen.main(ImBaumsuchen.java:24)
>
> (oclParser.java:122)
> 117 try {
> 118 // src/ocl_parser/ocl.g:102:9: ( ocl -> ^( OCL ocl ) )
> 119 // src/ocl_parser/ocl.g:102:9: ocl
> 120 {
> 121 pushFollow(FOLLOW_ocl_in_start193);
> 122 ocl1=ocl();
> 123 _fsp--;
> 124 if (failed) return retval;
> 125 if ( backtracking==0 ) list_ocl.add(ocl1.getTree());
>
> (oclParser.java:186)
> 182 try {
> 183 // src/ocl_parser/ocl.g:105:2: ( ( package_decl | context
> )+ )
> 184 // src/ocl_parser/ocl.g:105:2: ( package_decl | context )+
> 185 {
> 186 root_0 = (OclAst)adaptor.nil();
> 187
> 188 // src/ocl_parser/ocl.g:105:2: ( package_decl | context )+
> 189 int cnt1=0;
> 190 loop1:
> 191 do {
>
> I tried to make myAst extend DoublelinkTree or Commontree both with same
> effect
>
> when I use Commontree in my Grammar everything works fine.
>
> Alexander
>
> Terence Parr schrieb:
>
>> Where does it get the exception? Is it for the UP and DOWN nodes?
>> Ter
>> On Feb 20, 2007, at 2:50 AM, Alexander Gängel wrote:
>>
>>
>>> Can Somebody give me a hint how to use DoubleLinkTrees.
>>>
>>> I tried it this way:
>>>
>>> I have
>>> ASTLabelType=MyAst; in my V3 Grammar
>>>
>>> I created a Class MyAst extends DoubleLinkTree
>>>
>>> I Implemented the Abstract functions from BaseTree like in CommonTree
>>>
>>> but when I try to use the Grammar I get Exception in thread "main"
>>> java.lang.ClassCastException: org.antlr.runtime.tree.CommonTree
>>>
>>> Alexander
>>>
>>>
--
Alexander Gängel
Hirschberger Allee 39
68526 Ladenburg
Tel. : +49 (6203) 936399
Handy: +49 (177) 7692314
More information about the antlr-interest
mailing list