[antlr-interest] There is any documetation I can check; Fwd: How should I extend CommonTreeNodeStream?

Marwan Ajraoui marwan.alephn at gmail.com
Thu Aug 13 12:47:39 PDT 2009


---------- Forwarded message ----------
From: Marwan Ajraoui <marwan.alephn at gmail.com>
Date: 2009/8/13
Subject: How should I extend CommonTreeNodeStream? Do I need to change
my adaptor or something else?
To: antlr-interest at antlr.org


Hi there;

I did define a customized node, extending a commonTree, defined an
adaptor extending a  CommonTreeAdaptor, for my semantic analysis.

I did extend as well CommonErrorNode;

And now myAdaptor look like:

public class BTLTreeAdaptor extends CommonTreeAdaptor{
       @Override
       public Object create(Token payload) {
               return new BTLNodeTree(payload);
       }
       @Override
       public Object errorNode(TokenStream input, Token start, Token stop,
RecognitionException e) {
               return new BTLErrorNode(input, start, stop, e);
       }

Now I supose, that I have to extend CommonTreeNodeStream because I'm
getting a classCastExcpetion, I didn't find any information in the
book:
The Definitive ANTLR Reference, about how to deal with that. I'm using
ANTLR v3.1.

How should I extend CommonTreeNodeStream? Do I need to change my
adaptor or something else? My customized node tree has just few
attributes, to allow the walker to analyze the semantic of the
language I'm defining.

My customized node tree look like:

public class BTLNodeTree extends CommonTree {

       public Identificador identificador;
       public SymbolConst symbolConst;
       public String expType = "";
       public String expSecType = "";

       public BTLNodeTree(Token t)
       {
                super(t);
       }
}


Thx in advance for your help,

Cheers

--
Marouane



-- 
Marouane


More information about the antlr-interest mailing list