At 01:52 12/11/2008, Hendrik Maryns wrote:
 >The thing I am having trouble with is that, with the idea of
 >polymorphism etc., I'd like to have things dealt with at the
 >appropriate place.
 >
 >I have rules like
 >
 >atomic : atomicHead variable label ;
 >
 >atomicHead : EQUALITY | DOMINANCE | INCLUSION | … ;
 >
 >and depending on the value of atomicHead, I 
want a different Java
 >object to be created.

If you have input AST fragments like this:
   ^(EQUALITY a b)
   ^(DOMINANCE a b)
   ^(INCLUSION a b)
   ^(INVERSE a)

then they're trivial to parse with AST 
rules.  The job of the parser is usually to 
translate the sequential token stream into a tree 
structure that conveys the intended meaning; the 
tree parser then goes through that tree and does 
whatever you want.  The tree grammar is usually 
very simple and you should almost never need to 
use any predicates in it.

(Though I'm not sure why you're calling this 
"atomic".  It seems like an odd choice of name 
for something that seems to require neighbouring symbols as well.)

 >I cannot do
 >
 >atomic return [Formula result] : atomicHead[$variable.result,
 >$label.result] variable label { $result = $atomicHead.result; };
 >
 >since $variable.result and $label.result will not have been
 >evaluated at that point.

atomic returns [Formula result]
   : ^(EQUALITY variable expr) { $result = new
         Equality($variable.result, $expr.result); }
   | ^(DOMINANCE ...


List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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