[antlr-interest] Suppress Warning Message
Priya Suresh
meetvijaysuresh at rediffmail.com
Wed Sep 15 04:11:07 PDT 2004
Hi,
When i execute my grammer file. I got WARNING MESSAGE LIKE
"warning message nondeterminism". I want to suppress this warning
messae throught the process.
"I don't want to see this warning message". Is there any other option
present for that.. I have tried to use "warnWhenFollowAmbig option"
I don't know how and where to use this option.
Code which I have
Error I am getting
CdFa.g: warning:lexical nondeterminism between rules CD and ALPHANUM
upon
CdFa.g: k==1:'c'
CdFa.g: k==2:'d'
CdFa.g: k==3:<end-of-token>
CdFa.g: k==4:<end-of-token>
CdFa.g: k==5:<end-of-token>
CdFa.g: k==6:<end-of-token>
CdFa.g: warning:lexical nondeterminism between rules FA and ALPHANUM
class CdFaParser extends Parser;
options
{
k = 2;
buildAST = true; // uses CommonAST by default
defaultErrorHandler = false;
}
// Define some variables to be used in the parser
{
/**
* To track the # of times the directory name arg is
entered
*/
int directoryCount;
/**
*max length of the arg entered
*/
int maxLength = 100;
HashMap hmap = null;
}
/**
* The Command entered by the user is checked for its validity.
*
* @param nil
* @returns the hash map containing the command and its params.
* @exception IndigoException
*/
startRule returns[HashMap hmapRet = null] throws IndigoException
{
hmapRet = new HashMap();
hmap = hmapRet;
}
:
(changeDirectory
)EOF
;
/**
* The Command syntax for Change directory and its corresponding
actions
*
* @param nil
* @return nil.
* @exception IndigoException
*/
changeDirectory throws IndigoException
:
CD WS FA (WS cdParams)* NEWLINE
{
hmap.put("verb", "Cd");
hmap.put("object","Fa");
if (directoryCount == 0)
{
throw new MissingParameterException("directorypath");
}
}
;
/**
* The syntax for Change directory command arguments and its
corresponding actions
*
* @param nil
* @return nil.
* @exception IndigoException
*/
cdParams throws IndigoException
: setDirectorypath
| setError
;
setDirectorypath throws IndigoException
:
DIRECTORYPATH (WS)? a:ALPHANUM
{
if (directoryCount == 1)
{
throw new ParameterRepeatedException("Directorypath");
}
String directorypath = a.getText().trim();
if ((directorypath.equals("="))||((directorypath.equals
(""))))
{
throw new MissingParameterValueException
("Directorypath");
}
if (!isStringValid(directorypath))
{
throw new InvalidParameterValueException("Directorypath");
}
hmap.put("Directorypath", directorypath);
directoryCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException("Directorypath");
}
;
setError throws IndigoException
:
unknownParam:ALPHANUM
{
if (true)
{
throw new UnknownParameterException(unknownParam.getText
());
}
}
;
/**
* Checks whether the entered param is a valid string
*
* @param string containing the input param
* @return boolean true/false.
* @exception nil.
*/
isStringValid[String inputStr] returns [boolean bRetVal = true]
:
{
String patternMatch = "['\'\\a-zA-Z\\d#$\\-\\_\\.]*";
if (inputStr.matches(patternMatch))
{
if (inputStr.length() > maxLength)
{
bRetVal = false;
}
}
else
{
bRetVal = false;
}
}
;
/**
* A CdFaLexer class representing
* lexer for Make directory.
*
* @author padmaja
* @version 1
*/
// Lexer framework (rule contents are missing here)
class CdFaLexer extends Lexer;
options
{
k = 6;
caseSensitiveLiterals = false;
caseSensitive = false;
charVocabulary = ' '..'~' ;
}
// Definitions of verbs
CD : "cd";
// Definitions of objects
FA : "fa";
// Definitions of the parameters
DIRECTORYPATH:"dirpath";
WS : (' ' | '\t')+;
NEWLINE : '\n';
ALPHANUM
options { testLiterals = true; }
: ('=') => '='! (WS!)? (~(' ' | '\n' | '\t'))+
| (~(' ' | '\n' | '\t'))+
;
" Give me solution for that AEAP. "
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