I did find how to implement it;
1. changed my main class setting a walker myAdator
// Create a tree Walker attached to the nodes
stream
BTLSem walker = new BTLSem(nodes);
//setting the adapter to use
walker.setTreeAdaptor(adaptor);
2. overrides public Tree dupNode() in MyAdaptor
3. overrides public Tree dupNode() in MyNodeTree since is called by
the one is overriden in the point 2
Hope that will save little time, to others new bites like me, that get
lost with so many options of use of this framework and considerably
poor documentation in proportion. That's the common problem of
opensource projects :-(
Cheers,
2009/8/13 Marwan Ajraoui <[email protected]>:
> ---------- Forwarded message ----------
> From: Marwan Ajraoui <[email protected]>
> Date: 2009/8/13
> Subject: How should I extend CommonTreeNodeStream? Do I need to change
> my adaptor or something else?
> To: [email protected]
>
>
> 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
>
--
Marouane
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---