On Wednesday 06 May 2009 23:05:09 Tilman Bender wrote:
>
> 1. How can I throw a detailed Error Message saying something like "The
> operator + is invald for the types of "+ $a.returntype + " and "+
> $b.returntype

either throw an exception (in your if-statements) or print to stderr (or use 
java logging) to print the error (your if statements catch the incorrect 
combinations)

> 2. How can I modifiy the tree returned by $a so that I can replace
> every token like INT:3 with a token of FLOAT:3.0.  So that (+ 3 4.0)
> becomes (+ 3.0 4.0)

I haven't done this with antlr, but in this case just generate a new tree as 
output (OUTPUT= AST) of the pass over the first tree, even if only few parts of 
tree actually changes. After that you have a tree with casting inserted.
I don't know if a treeparser can generate a new tree, but more than one passes 
are common.

 Michael


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to