[antlr-interest] distinguishing between int and double in a tree grammar

Michael micha-1 at fantasymail.de
Mon Mar 16 03:45:34 PDT 2009


Am Monday 16 March 2009 11:12:02 schrieb Anders Hessellund:
> Hi,
>
> It is important to distinguish between these types because integer division
> and double division return very different results. I guess someone must
> have looked at this when doing type conversions/coercions. Here is my tree
> grammar:

you give the type to the constants and variables and when going over the tree 
the operators decide on their argument types what to coerce 

so 3 is an int and 5.4 is a double, now "/" has an int and a double as 
arguments so it can insert a coercion from int to double for it's first 
parameter (or force you to write a coercion)...

if "/" gets a boolean and a char it can throw a type error...


 Michael


More information about the antlr-interest mailing list