[antlr-interest] Lables for tokens cause "cannot resolve symbol" errors

Monty Zukowski monty at codetransform.com
Mon Aug 16 21:28:40 PDT 2004


A rule could return multiple tokens, so ANTLR doesn't even assign the 
first token to the label, it only allows trees for rule labels.  When 
you match a token in a rule then you can treat it like a token or a 
node depending on if you use the # character in front of the label.

Monty

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html

On Aug 16, 2004, at 4:03 PM, charlweed wrote:

> Hi,
> I'm trying to mod a Java grammer, but when ever I try to create  a
> lable for a token, I get a "cannot resolve symbol" chen I compile the
> JavaRecogniser. AST lables work fine. Is there some odd config that is
> messed up somewhere?
>
> In the eample below, note that the identifier assignmentTokens_AST IS
> generated, but plain assignmentTokens is not.....
>
>
> expression
> 	:  assignmentTokens :assignmentExpression
> 	   {
>            #expression = #(#[EXPR,"EXPR"],#expression);
>            _engine.wrapWithSetter((IndexedToken)assignmentTokens);
>            }
> 	;
>
>
> 	public final void expression() throws RecognitionException,
> TokenStreamException {
> 		
> 		returnAST = null;
> 		ASTPair currentAST = new ASTPair();
> 		AST expression_AST = null;
> 		AST assignmentTokens_AST = null;
> 		
> 		assignmentExpression();
> 		assignmentTokens_AST = (AST)returnAST;
> 		astFactory.addASTChild(currentAST, returnAST);
> 		if ( inputState.guessing==0 ) {
> 			expression_AST = (AST)currentAST.root;
> 			
> 			expression_AST = (AST)astFactory.make( (new
> ASTArray(2)).add(astFactory.create(EXPR,"EXPR")).add(expression_AST));
> 			_engine.wrapWithSetter((IndexedToken)assignmentTokens);/*"cannot
> resolve symbol" Error!*/
> 			
> 			currentAST.root = expression_AST;
> 			currentAST.child = expression_AST!=null
> &&expression_AST.getFirstChild()!=null ?
> 				expression_AST.getFirstChild() : expression_AST;
> 			currentAST.advanceChildToEnd();
> 		}
> 		expression_AST = (AST)currentAST.root;
> 		returnAST = expression_AST;
> 	}
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list