[antlr-interest] Summing values from "+="

Michael Bedward michael.bedward at gmail.com
Thu Feb 12 03:50:29 PST 2009


At the start of the rule the generated parser code will have...

var e:Token=null;
var list_e:Array=null;

and then in the sumStat rule loop...

if (list_e==null) list_e=new Array();
list_e.push(e);

Hope this helps,
Michael


2009/2/12 Des Hartman <des at deshartman.com>:
> I have a simple function to sum values, where expression is numbers with
> operands, etc.
>
> sumStat    :    'SUM' '('  (e+=expression (',' e+=expression)+) ')' ->
> ^('SUM' $e);
>
> What I need to know is how I write the action statements to add the various
> numbers? Just to complicate it I am doing it using Flex ActionScript? If I
> understand it correctly += returns a Java List, so what would be returned
> with ActionScript?
>
> ^('SUM' e=expression) {$value =??????;}
>
> Thanks
> Des
>
>
>
> 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