[antlr-interest] adding a subtree to the left side of a rewrite rule which doesn't have a corresponding left side element ?
Terence Parr
parrt at cs.usfca.edu
Sat Jan 8 12:30:33 PST 2011
if newSubTree is some random tree you create not with antlr, then do
>> program : bla1 bla2 bla3 -> ^( 'P' bla1 bla2 {newSubTree} bla3 ) ;
T
On Jan 8, 2011, at 12:16 PM, Roland Braito wrote:
> 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 <parrt at cs.usfca.edu>
>> An: r.b.lists at gmx.net
>> CC: antlr-interest at antlr.org
>> 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, r.b.lists at gmx.net 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
More information about the antlr-interest
mailing list