Thanks a lot Sam & Ter. Your answers helped a lot!

Bruno M-A
--
Bruno Marc-Aurèle
courriel Poly: [email protected]
courriel perso: [email protected]


Selon Sam Harwell <[email protected]>:

> You'll also see to call setTreeAdaptor (java target) in the @init section of
> the entry rule(s) to your grammar. Your implementation of TreeAdaptor should
> include implementations of at least the following 2 functions (example here
> is the C# target just because I had it ):
>
> class GrammarASTAdaptor : CommonTreeAdaptor
> {
>     public override object create( IToken payload )
>     {
>         GrammarAST t = new GrammarAST( payload );
>         return t;
>     }
>     public override object errorNode( ITokenStream input, IToken start,
> IToken stop, RecognitionException e )
>     {
>         GrammarAST t = new GrammarASTErrorNode( input, start, stop, e );
>         return t;
>     }
> }
>
> Sam
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Terence Parr
> Sent: Friday, February 06, 2009 9:56 AM
> To: Bruno Marc-Aurele
> Cc: [email protected]
> Subject: Re: [antlr-interest] Changing the base node type
>
> Hi. There should be a faq entry on this or an example.  Implement
> TreeAdaptor :)
> Ter
> On Feb 6, 2009, at 6:17 AM, Bruno Marc-Aurele wrote:
>
> > Hello all,
> >
> > I am trying to do a grammar with a new base type for nodes. I can
> > see that I am
> > provided with ASTLabelType, whose value I set to Node, the name of my
> > CommonTree subclass. The only difference between the two classes is
> > the
> > presence of a "Accept" method. The parser, however, still creates
> > CommonTree
> > nodes (of course, the ITreeAdaptor is still a CommonTreeAdaptor).
> >
> > What would be the suggested method to make my parser create Node
> > objects instead
> > of CommonTree objects?
> >
> > Thanks a lot,
> > Bruno M-A.
> >
> > P.S.: I am using the C#2 target.
> > --
> > Bruno Marc-Aurèle
> > courriel Poly: [email protected]
> > courriel perso: [email protected]
> >
> >
> >
> >
> >
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


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
-~----------~----~----~----~------~----~------~--~---

Reply via email to