[antlr-interest] Understanding "element labels"

Jorge Scandaliaris j_scandaliaris at yahoo.es
Sat Feb 22 02:23:03 PST 2003


I've been struggling to understand how to use element labels within the
parser. What I am trying to do is:

rule	:	"some_literal1" id:ID "some_literal2"	// ID is a token
reference
				.
				.		
				.
		(name:parser_rule_reference
{id->getText()==name->getText();}?)?
	;

parser_rule_reference 
	:	ID
	;

I wanted to validate with a semantic predicate that the text of both
labels is the same, but the second element label is not declared by
antlr in the parser's c++ code and then I get error compile errors.
I can use ID instead of parser_rule_reference and that will work. So my
question is more:
What are the limitations of using element labels? In antlr doc it
mentions both atomic elements and rule references, but it seems that the
latter is intended for AST (currently off in my parser). Am I right? Am
I missing a basic point here? What other ways I would have to this?

I appreciate any help. Thanks.
		


___________________________________________________
Yahoo! Móviles
Personaliza tu móvil con tu logo y melodía favorito 
en http://moviles.yahoo.es

 

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



More information about the antlr-interest mailing list