Am 17.11.2011 02:39:05 schrieb(en) John B. Brodie: > On 11/16/2011 12:02 AM, Voelkel, Andy wrote: > > : : : > > array > > : ( l='[' (f+=FLOAT)+ ']' -> ^(ARRAY_FLOAT ["FLT ARY",$l] $f+) ) > > | ( l='[' (s+=STRING)+ ']' -> ^(ARRAY_STRING["STR ARY",$l] $s+) ) > > ; > > > > [Andy - This causes compiler errors, and I'm really not sure what you are > getting at. > > compiler errors are odd here, maybe the C# target does not support the [ > ] notation for initializing an imaginary token?
To be specific on this example only: I believe the order of the parameters (in []) in the rewrite section is wrong. First comes the token reference then follows the text for the imaginary node. array : ( l='[' (f+=FLOAT)+ ']' -> ^(ARRAY_FLOAT [$l,"FLT ARY"] $f+) ) | ( l='[' (s+=STRING)+ ']' -> ^(ARRAY_STRING[$l,"STR ARY"] $s+) ) ; See Chapter 7, p. 176 "Deriving Imaginary Nodes from Real Tokens" in the ANTLR Reference Book (print 02). > > > i think this last form will simplify subsequent processing of the tree. > > note also the proper initialization of the imaginary tokens. > > > > [Andy - what do you mean "proper initialization of the imaginary tokens"] > > the stuff between the [ ] on the right hand side of the -> is > information used to initialize the imaginary token. in Java, they get > translated into parameters to its constructor. i refer you to Dr. Parr's > book to find out more about this feature. Regards, Stefan 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 il-antlr-inter...@googlegroups.com. To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en.