[antlr-interest] How can I modify a tree node value according to the value of another tree node ?

Michael Bedward michael.bedward at gmail.com
Mon Mar 16 17:34:03 PDT 2009


Hi Annie,

One way to pass data between sub-trees is to use global scope.  See
section 4.5 in the ANTLR book.

Hope this helps
Michael



2009/3/17 YINGAnnie <yimm8369 at hotmail.com>:
>
> Hi everyone,
>
>
> What I want to do is to replace var t:Number=Math.ceil(1.5);  to  var
> t:int=int(1.5); The tree I got is something like this:
>
> PROPERTY_DECL (VARIABLE_STATEMENT (VAR_DECL_LIST (VAR_ID_DECL t
> (QUALIFIED_NAME Number)) = (ASSIGNMENT_EXPRESSION (CONDITION_EXPRESSION
> (...........(QUALIFIED_NAME Math . ceil))) (ARGUMENT_SUFFIX
> (.........(PRIMARY_EXPRESSION 1.5))))
>
> ....... stands for some other nodes.
>
>
> Replacing Math.ceil(1.5) to int(1.5) is easy to implement.But cos Number
> rule and Math.ceil rule belong to different tree, how can I replace Number
> to int when value of the other tree's node equals to Math.ceil?
>
> Thanks in advance!
>
>
> Annie
>
> ________________________________
> 微软地图实时路况,为您节省的不仅仅是时间! 立即查看!
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>


More information about the antlr-interest mailing list