[antlr-interest] ANTLR Option warnWhenFollowAmbig

David Wigg wiggjd at sbu.ac.uk
Wed Dec 18 08:50:24 PST 2002


We have been converting a grammar file from using PCCTS to using 
ANTLR 2.7.1.

I am now trying to remove ALL warnings resulting from generation 
of the grammar file, but I don't seem to be able to get rid of 
the one shown below using "options {warnWhenFollowAmbig = 
false;}:" in class_specifier rule shown below.

As you will see, I have replaced "#pragma approx" outside the 
brackets with "options {warnWhenFollowAmbig = false;}:" within 
the brackets which seems to work elsewhere.

However, having read 
http://www.antlr.org/doc/options.html#warnWhenFollowAmbig
I am beginning to wonder if it is always possible to turn 
unwanted warnings off as it may depend on the structure of the 
rule. I hope not, as I think we should be able to remove all 
unwanted warnings.

Please could someone clarify the situation and, if at all 
possible, let me know how I could get this warning turned off.

Thanks.

David.

CPP_parser.g:697: warning: nondeterminism upon
CPP_parser.g:697: 	k==1:ID
CPP_parser.g:697: 	k==2:COLON
CPP_parser.g:697: 	between alts 1 and 3 of block

class_specifier[DeclSpecifier ds] returns 
[CPPParser::TypeSpecifier ts]
{char *saveClass;}
	:	("struct"	{ts=tsSTRUCT;}
		|"union"	{ts=tsUNION;}
		|"class" 	{ts=tsCLASS;classDefinition= 1;in_class_def = true;}
		)
		//#pragma approx // indicate that ambig between alts 1 and 3 is ok
		(options {warnWhenFollowAmbig = false;}:
			(id:ID
			{saveClass = enclosingClass;
			enclosingClass = 
symbols->strdup(const_cast<char*>((id->getText()).data()));
			}
			( base_clause )?
			LCURLY	
			{beginClassDefinition(ts, (id->getText()).data()); 
in_class_def = true;}
			(member_declaration)*
			{endClassDefinition();in_class_def = false;}
			RCURLY
			{enclosingClass = saveClass;struct_flag = 1;}
			)
		|
			(LCURLY	
			{saveClass = enclosingClass; enclosingClass = "__anonymous";}
			{beginClassDefinition(ts, "anonymous");}
			(member_declaration)*
			{endClassDefinition();}
			RCURLY
			{enclosingClass = saveClass;struct_flag = 1;}
			)
		|	(
			tag:ID
			(options {warnWhenFollowAmbig = false;}:
			LESSTHAN template_argument_list GREATERTHAN
			)?
			{id_type = ID_VAR_NAME; // DW 3/4/01
			classForwardDeclaration(ts, ds, (tag->getText()).data());
			})
		)
	;



 

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



More information about the antlr-interest mailing list