ANTLR/ST "return" types.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, September 28, 2007 01:11 PM

I have successfully ported about 1/2 of the ANTLR Runtime to AS3 (ActionScript 3), and I am in the process of creating the templates. However, there is one quirk that has me stumped silly. Taking a rule from the Expression Evaluator wiki page: atom returns [int value] : INT {$value = parseInt ( $INT.text );} | ID { var v:Number = memory [ $ID.text ]; if ( v != null ) $value = v; else trace ( "undefined variable " + $ID.text ); } | '(' expr ')' { $value = $expr.value; } ; How the heck do I format the "int value" syntax. I cannot find anything that formats this my edited Java template.    More>>

I have successfully ported about 1/2 of the ANTLR Runtime to AS3 (ActionScript 3), and I am in the process of creating the templates. However, there is one quirk that has me stumped silly.



Taking a rule from the Expression Evaluator wiki page:



			
atom returns [int value]
: INT {$value = parseInt ( $INT.text );}
| ID
{
var v:Number = memory [ $ID.text ];
if ( v != null ) $value = v;
else trace ( "undefined variable " + $ID.text );
}
| '(' expr ')' { $value = $expr.value; }
;



How the heck do I format the "int value" syntax. I cannot find anything that formats this my edited Java template.
Changing ruleDeclarations to


			
<>else <>initValue(a.type) ;


does not seem to help. It always comes out as int exprXX = 0; (Or, in the edited AS3 grammar, Number exprXX = 0; which is still not correct.




Thanks in advance.

   <<Less
About | Sitemap | Contact