As alqays thanks for the quick reply. I'll implement your suggestions and see how it goes.
Thanks Des Hartman +614 01 277 115 iPhone junky On 17/03/2009, at 14:21, George Scott <[email protected]> wrote: > Des, > > Tree rewrites and filters should work. I think the only problem is > you are missing a "var" declaration in your rule when you declare > iref. Also, you will get a runtime error if you try to pass in a > Number to construct a token type. You must use the "int" type, so > you should change your iref declaration to be int and the return > type of your function as well. For example: > > @members { > // This code needs to be implemented in a child class > public function convertLocalReference(ref:CommonTree):int > {return TokenConstants.INVALID_TOKEN_TYPE;} > > } > > reference > : ^(LREF lr=NAME) { var iref:int = > convertLocalReference($lr); } -> ^(IREF [iref]) > ; > > If you are not doing any processing in your convertLocalReference() > function then you can simplify futher to: > > reference > : ^(LREF lr=NAME) -> ^(IREF [$lr.type]) > ; > > > On Mon, Mar 16, 2009 at 6:51 PM, Des Hartman <[email protected]> > wrote: > George > > Is AST rewrite and Tree filters supported in ActionScript? I have > the following code, but keep ending up with weird compiled as file. > I have checked as many of the errors as I can, but want to make sure > I am not wasting time with an unsupported feature. > > ============================== > tree grammar L2ITree; > > options { > language=ActionScript; > tokenVocab=Formula; > output=AST; > ASTLabelType=CommonTree; > filter=true; > rewrite=true; > } > > @members { > // This code needs to be implemented in a child class > public function convertLocalReference(ref:CommonTree):Number > {return null;} > > } > > reference > : ^(LREF lr=NAME) { iref:Number = > convertLocalReference($lr); } -> ^(IREF [iref]) > ; > > ================================================= > > I have attached the formula grammar. > > Output errors are on the following lines of code: > > switch (alt1) { > case 1 : > <snip> > if ( this.state.backtracking==1 ) { > iref:Number = > convertLocalReference(lr); XXXXXXXXXX Implicit coersion of > Number and Class > } > <snip> > if ( this.state.backtracking==0 ) { > retval.tree = > root_0; XXXXXXXXXXXX > Property is Read-only > > var > stream_retval:RewriteRuleSubtreeStream=new > RewriteRuleSubtreeStream(adaptor,"token retval", retval!=null? > retval.tree:null); > <snip> > > // C:\\usr\\workspace\\SFXFormula\\src\ > \com\\wiredlizard\\grammar\\L2ITree.g:39:79: ^( IREF[iref] ) > { > var root_1:CommonTree = > CommonTree(adaptor.nil()); > root_1 = > CommonTree(adaptor.becomeRoot(CommonTree(adaptor.create(IREF, > iref)), root_1)); XXXXXXXXXXX Access of undefined property iref > > adaptor.addChild(root_0, root_1); > > <snip> > retval.tree = > CommonTree(adaptor.rulePostProcessing(root_0)); > XXXXXXXXXXXX Property is Read-only > > input.replaceChildren(adaptor.getParent(retval.start), > > adaptor.getChildIndex(retval.start), > > adaptor.getChildIndex(_last), > retval.tree);} > } > > Thanks > Des > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
