[antlr-interest] invoke subtemplates on multivalue attribute

Florian Barth antlr at florian-barth.de
Thu Apr 30 04:06:02 PDT 2009


Hi there!
Thank you for this hint. It works and the conds and thens are properly  
computed.
This solved problem number one, but the number two is still there.
If I feed the template with a list of values (that need further rules  
to be applied) the compiler still complains because of the multi- 
valued attribute:
[12:51:16] error(125): ResultGenerator.g:47:8: label conds type  
mismatch with previous definition: token-list!=rule-list
[12:51:16] error(125): ResultGenerator.g:48:8: label thens type  
mismatch with previous definition: token-list!=rule-list

I think this error message is related to the conds.st and then.st.  
With single values this works, but it is not applicable to multi- 
valued attributes.
I need to state something like
"for each value of value-list do
	apply further rules and apply the according template
return these values to super-template as list of evaluated strings"

Any ideas?

On 30.04.2009, at 12:12, Michael wrote:

> Am Thursday 30 April 2009 11:25:28 schrieb Florian Barth:
>> Hi everyone!
>> I'm writing a language transformator based on AntLR and I'm running
>> into some problems:
>> In order to transform conditional statement my parser constructs the
>> following AST:
>
>
>> The first problem I'm running into is that '?' and '*' seem to be not
>> allowed in tree grammars
>
> I think you must write it with parens like:   (^(NODE foo))*
> try this:
>
> cond    :       ^(IF
>                        ^(CONDITION conds+=condExpression)
>                        ^(THEN thens+=expression)
>                        (^(ELSEIF
>                                ^(conds+=CONDITION condExpression)
>                                ^(thens+=THEN expression)
>                        ))*
>                        (^(ELSE else=expression))?
>                )
>
>
> Michael



More information about the antlr-interest mailing list