Christian Hoffmann schrieb:
> What's wrong below????
> antlr error:  reference to rewrite element unaryExpression1 without reference 
> on left of ->
> 
> 
> unaryExpression1     // (level 1)
>   : a=INC        -> ^(TOK_PREINC[$a]) unaryExpression1
>   | a=DEC        -> ^(TOK_PREDEC[$a]) unaryExpression1
>   | unaryExpression2
>   ;

I'm not sure if you made a mistake here - "^(TOK_PREINC[$a])
unaryExpression1" may need to be "^(TOK_PREINC[$a] unaryExpression1)".
At least the resulting AST would make more sense to me. In fact,
thinking about your intent you probably want

 unaryExpression1     // (level 1)
   : a=INC unaryExpression1 -> ^(TOK_PREINC[$a] unaryExpression1)
   | a=DEC unaryExpression1 -> ^(TOK_PREINC[$a] unaryExpression1)
   | unaryExpression2
   ;

> 
> rewriting rules doesn't work, if you write something like:
> rule : expr -> ^(TOK_SLIST (statement)*)
>             { pVMCompiler->m_Symbols.PopScope(); }
>      ;
> cause C-Target code results in:
>       ADAPTOR->addChild(ADAPTOR, root_0,  pVMCompiler->m_Symbols.PopScope(); 
> );
>                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> the inlined code is inside the addChild(...) call

That is a mistake by you. Actions after "->" are only supposed to create
nodes and aren't supposed to contain complete statements.

rule : expr  { pVMCompiler->m_Symbols.PopScope(); } -> ^(TOK_SLIST
(statement)*)

or

rule : expr -> ^(TOK_SLIST (statement)*) {
pVMCompiler->m_Symbols.PopScope() }

may be your intent.

> 
> It seems the c-target is developped without beeing used in reality.
> I'll go back to antlr2, at this stage, antlr3 is nonviable...

Please don't rant about problems unless you are sure you aren't the
cause. While the second cause isn't obvious to newbies, I suspect you
haven't looked through the available grammars for better examples.
Although the C target requires special treatment - Jim always advises to
look at the C specific examples available on the wiki - the wrong
grammar syntax would have caused the same problems on any target.

Johannes
> 
> 
> ---
> Christian Hoffmann
> D-38118 Braunschweig
> 
> 
> 
> 
> 
> List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
> 


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