Hi! thanks for the quick reply!
However, the 'SL' token is not the problem, it's putting the list into a subtree and including that in the rewrite-rule's output. I'm sure the answer is very obvious, but i'm unable to see it right now. Thanks, R. -------- Original-Nachricht -------- > Datum: Sat, 8 Jan 2011 11:39:52 -0800 > Von: Terence Parr <[email protected]> > An: [email protected] > CC: [email protected] > Betreff: Re: [antlr-interest] adding a subtree to the left side of a rewrite > rule which doesn\'t have a corresponding left side element ? > hi. search for keyword "imaginary token" or imaginary node. > Ter > On Jan 8, 2011, at 11:05 AM, [email protected] wrote: > > > Hello All, > > > > Sorry for the confusing title... > > > > I'm trying to build an AST via rewrite rules. > > > > The input is a DSL which contains a number of possible constructs, > > including a description of state transitions. > > > > I'd like to build a list 1of all the states mentioned and include that > > list in the AST as something like ^( SL states+ ) > > > > What is the best way to do this? > > > > I tried to build a separate rule to extract the states from the input > > and insert it at the right side, but Antlr complains about referencing > > something on the right side which doesn't show up on the left side... > > > > example: > > > > program : bla1 bla2 bla3 -> ^( 'P' bla1 bla2 newSubTree bla3 ) ; > > > > leads to an error... > > > > Then i tried to set up a global scope and collect all the names in it , > > but i didn't find a way to transfer the list into a subtree from within > > the grammar... > > > > Do i really have to build the sub-tree by hand and include it manually, > > or is there a more efficient way? > > > > Thanks, > > R. > > > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > 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.
