[antlr-interest] help on warning:nondeterminism upon
s2jafer1
s2jafer1 at yahoo.com
Tue Oct 12 23:38:03 PDT 2004
I am getting the " warning:nondeterminism upon "
in the line no 244,it corresponds to
"createPolicy throws ArchiveSystemApplicationException
:
CREATE WS POLICY ( WS createPolicyParams)* ( WS
createPolicyTypes)* NEWLINE in the source code" during compilation
of the grammar file.i want to avoid this warning .
if anybody knows the solution let me know as soon as possible.
the source code is :
header{
/**
* File Name : CreatePolicy.g
*/
}
/**
* A Parser class for validating the create policy command
*/
class CreatePolicyParser extends Parser;
options
{
k = 9;
buildAST = true; // uses CommonAST by default
defaultErrorHandler = false;
}
// Define some variables to be used in the parser
{
/**
* A hash map for Create Copy verb
*/
HashMap cCPHash;
/**
* A array list for Create Copy verb
*/
ArrayList createCopyList = new ArrayList();
/**
* To track the # of times the create copy verb is entered
*/
int createCopyCount;
/**
* A hash map for migrate verb
*/
HashMap migrateHash;
/**
* A array list for migrate verb
*/
ArrayList migrateList = new ArrayList();
/**
* To track the # of times the migrate verb is entered
*/
int migrateCount;
/**
* A hash map for Log verb
*/
HashMap logMap;
/**
* To track the # of times the read access arg is entered
*/
int lgReadAccessCount ;
/**
* To track the # of times the datastorage arg is entered
*/
int lgintdatastrgCount;
/**
* To track the # of times the dupdatadetection arg is
entered
*/
int lgdupDataDetCount ;
/**
* To track the # of times the data alter arg is entered
*/
int lgDataAlterCount ;
/**
* To track the # of times the migrate verb is entered
*/
int mgverbCount;
/**
* To track the # of times the createcopy verbid is entered
*/
int cCPverbCount;
/**
* To track the # of times the log verbid is entered
*/
int lgverbCount;
/**
* To track the # of times the migrate relative duration is
entered
*/
int mgRelDur;
/**
* To track the # of times the policyname arg is entered
*/
int policyNameCount;
/**
* To track the # of times the policy descr arg is entered
*/
int policyDescrCount;
/**
* To track the # of times the policy name length arg is
entered
*/
int policyNameLength=40;
/**
* To track the # of times the policydescr length arg is
entered
*/
int policyDescLength=255;
/**
* To track the # of times the log verb is entered
*/
int logSectionCount;
/**
* To track the # of times the create copyname arg is
entered
*/
int cCpCopyNoCount;
/**
* To track the # of times the destinationpool arg is
entered
*/
int ccpDestinationPoolCount;
/**
* To track the # of times the retention arg is entered
*/
/**
* To track the max ln of the arg entered
*/
int maxLength=100;
/**
* To track the # of times the srccpyname arg is entered
*/
int mgSrcCopyNoCount;
/**
* To track the # of times the destinastion pool arg is
entered
*/
int mgDestinationPoolCount;
/**
*hash map containing the cmd and its params
*/
HashMap hmap = null;
/**
* To track the # of times the migrate abs starttime arg
is entered
*/
int mgAbsStTime ;
/**
* To track the # of times the migrate rel starttime arg
is entered
*/
int mgRelStTime ;
/**
* To track the # of times the rel to arg is entered
*/
int mgRelTo;
/**
* To track the # of times the starttime is entered
*/
int cCPStartTimeCount;
/**
* To track the # of times the absretentime is entered
*/
int cCpAbsRetentionCount;
/**
* To track the # of times the retentionduration is entered
*/
int cCPRetentionDur;
/**
* attributes of date
*/
int year = 0;
int month = 0;
int day = 0;
int hours = 0;
int min = 0;
}
/**
* The Command entered by the user is checked for its validity.
*/
startRule returns[HashMap hmapRet = null] throws
ArchiveSystemApplicationException
{
hmapRet = new HashMap();
hmap = hmapRet;
}
:
(createPolicy
)EOF
;
/**
* The Command syntax for create policy and its corresponding
actions
*
* @param nil
* @return nil.
*/
createPolicy throws ArchiveSystemApplicationException
:
CREATE WS POLICY ( WS createPolicyParams)* ( WS
createPolicyTypes)* NEWLINE
{
hmap.put("verb", "Create");
hmap.put("object", "Policy");
if(policyNameCount ==0)
{
throw new MissingParameterException
("policyname");
}
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterException("create policy");
}
catch[ Exception e ]
{
e.printStackTrace();
}
;
/**
* The syntax for create policy command arguments and its
corresponding actions
*
* @param nil
* @return nil
*/
createPolicyParams throws ArchiveSystemApplicationException
:setPolicyName
|setPolicyDescr
|setError
;
setPolicyName throws ArchiveSystemApplicationException
{
ArrayList policyNameList = new ArrayList();
}
:
POLICYNAME (WS)? policyname:ALPHANUM
{
if (policyNameCount == 1)
{
throw new ParameterRepeatedException
("policyname");
}
String policyName = policyname.getText().trim();
if ((policyName.equals("="))||((policyName.equals
(""))))
{
throw new MissingParameterValueException
("policyname");
}
if (!isStringValid(policyName))
{
throw new InvalidParameterValueException
("policyname");
}
if( policyName.length() > policyNameLength)
{
throw new InvalidParameterValueException
("policyname");
}
hmap.put("policyname", policyName);
policyNameCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("policyname");
}
;
setPolicyDescr throws ArchiveSystemApplicationException
:
POLICYDESCR (WS)? policydescr:ALPHANUM
{
if (policyDescrCount == 1)
{
throw new ParameterRepeatedException
("policydescr");
}
String policyDesc= policydescr.getText().trim();
if ((policyDesc.equals("="))||(policyDesc.equals("")))
{
throw new MissingParameterValueException
("policydescr");
}
if (!isStringValid(policyDesc))
{
throw new InvalidParameterValueException
("policydescr");
}
if((policyDesc.length() ) > policyDescLength)
{
throw new InvalidParameterValueException
("policydescr");
}
hmap.put("policydescr", policyDesc);
policyDescrCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("policydescr");
}
;
createPolicyTypes throws ArchiveSystemApplicationException
:setCreateCopy
|setMigrate
|setLog
|setError
;
setCreateCopy throws ArchiveSystemApplicationException
{
cCPHash = new HashMap();
cCpCopyNoCount =0;
ccpDestinationPoolCount =0;
cCPStartTimeCount = 0;
cCpAbsRetentionCount= 0 ;
cCPRetentionDur = 0;
}
:
CREATECOPY (WS)? (OPAREN) (WS crPlCcpParams)* (WS)?
(CPAREN)
{
if(cCpCopyNoCount ==0 )
{
throw new MissingParameterValueException
("CreateCopy::CreateCopyNo");
}
if(ccpDestinationPoolCount == 0)
{
throw new MissingParameterValueException
("CreateCopy::destinationpool");
}
if(cCPStartTimeCount == 0)
{
throw new MissingParameterValueException
("CreateCopy::starttime");
}
//either absretention time or retention duration can
be present
if((cCpAbsRetentionCount ==1) &&(cCPRetentionDur ==1))
{
throw new EitherOrParameterException
("AbsoluteretentionTime","Retentionduration");
}
if((cCpAbsRetentionCount ==0) &&(cCPRetentionDur ==0))
{
throw new EitherOrParameterException
("AbsoluteretentionTime","Retentionduration");
}
createCopyList.add(cCPHash);
hmap.put("createcopy",createCopyList);
createCopyCount++;
}
;
crPlCcpParams throws ArchiveSystemApplicationException
: setcCPcopyName
| setcCPdestinationPool
| setcCPRetentionDuration
| setcCPAbsRetentionTime
| setcCPstartTime
| setError
;
setcCPcopyName throws
ArchiveSystemApplicationException
:
COPYNAME (WS)? copyNo:ALPHANUM
{
if( cCpCopyNoCount == 1)
{
throw new ParameterRepeatedException
("CreateCopy::copyname");
}
String cpynum = copyNo.getText().trim();
if((cpynum.equals("="))||(cpynum.equals("")))
{
throw new MissingParameterValueException
("copyName");
}
if(!(isStringValid(cpynum)))
{
throw new
InvalidParameterValueException("copyName");
}
cCpCopyNoCount++;
cCPHash.put("copyname",cpynum);
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("copyName");
}
;
setcCPdestinationPool throws ArchiveSystemApplicationException
:
DESTINATIONPOOL (WS)? ccpDestPool:ALPHANUM
{
if( ccpDestinationPoolCount == 1)
{
throw new ParameterRepeatedException
("CreateCopy::destination pool");
}
String destPool= ccpDestPool.getText().trim();
if ((destPool.equals("="))||(destPool.equals("")))
{
throw new MissingParameterValueException
("CreateCopy::destination pool");
}
if (!isStringValid(destPool))
{
throw new InvalidParameterValueException
("CreateCopy::destination pool");
}
cCPHash.put("destinationpool", destPool);
ccpDestinationPoolCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("CreateCopy::destination pool");
}
;
setcCPRetentionDuration throws ArchiveSystemApplicationException
:
RETENTIONDURATION (WS)? rttime:ALPHANUM
{
if( cCPRetentionDur == 1)
{
throw new ParameterRepeatedException
("CreateCopy::retention duration");
}
String rtTime = rttime.getText().trim();
if((rtTime.equals("="))||(rtTime.equals("")))
{
throw new MissingParameterValueException
("CreateCopy::retention duration");
}
if(!(isRelativeTimeValid(rtTime)))
{
throw new OptionParameterValueException
("CreateCopy::retention duration: any number follwed by d/m/y");
}
cCPHash.put("retentionduration",rtTime );
cCPRetentionDur++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("CreateCopy::retention duration");
}
;
setcCPstartTime throws ArchiveSystemApplicationException
:
STARTTIME (WS)? sttime:ALPHANUM
{
if(cCPStartTimeCount == 1)
{
throw new ParameterRepeatedException
("CreateCopy::starttime");
}
String strtTime = sttime.getText().trim();
if((strtTime.equals("="))||(strtTime.equals("")))
{
throw new MissingParameterValueException
("CreateCopy::starttime");
}
if (!(strtTime.equals("0")) ){
if (!(isRelativeTimeValid(strtTime))){
throw new
OptionParameterValueException("CreateCopy::starttime: 0 or #of days
or # of months or # of years");
}
}
cCPHash.put("starttime",strtTime);
cCPStartTimeCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("CreateCopy::starttime");
}
;
setcCPAbsRetentionTime throws ArchiveSystemApplicationException
:
ABSOLUTERETENTIONTIME (WS)? prttime:ALPHANUM
{
if(cCpAbsRetentionCount ==1)
{
throw new ParameterRepeatedException
("CreateCopy::retentiontime");
}
String rtTime = prttime.getText().trim();
if((rtTime.equals("="))||(rtTime.equals("")))
{
throw new MissingParameterValueException
("CreateCopy::retentiontime");
}
if(!(isDateValid(rtTime)))
{
throw new OptionParameterValueException
("CreateCopy::retentiontime: any number followed by d/m/y");
}
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, day, hours, min, 0);
Date dateFormat = calendar.getTime();
cCPHash.put("absoluteretentiontime",dateFormat);
cCpAbsRetentionCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("CreateCopy::retentiontime");
}
;
setMigrate throws ArchiveSystemApplicationException
{
migrateHash = new HashMap();
mgSrcCopyNoCount = 0;
mgDestinationPoolCount = 0;
mgAbsStTime = 0;
mgRelStTime = 0;
mgRelTo = 0;
mgRelDur = 0;
}
:
MIGRATE (WS)? (OPAREN)(WS crPlMigrateParams)* (WS)? (CPAREN)
{
if(mgSrcCopyNoCount ==0 )
{
throw new MissingParameterValueException
("Migrate::CopyName ");
}
if(mgDestinationPoolCount ==0)
{
throw new MissingParameterValueException
("Migrate::destinationpool");
}
//either absstarttime or relstarttime can be present.but not
both
if((mgAbsStTime ==1)&& (mgRelDur ==1))
{
throw new EitherOrParameterException
("AbsolutestartTime","Relativeduration");
}
if((mgAbsStTime ==0)&& (mgRelDur ==0))
{
throw new EitherOrParameterException
("AbsolutestartTime","Relativeduration");
}
if ((mgRelDur == 1) && (mgRelTo==0))
{
throw new MissingParameterException
("relativestarttimeto");
}
if((mgAbsStTime ==1)&& (mgRelTo ==1))
{
throw new EitherOrParameterException
("AbsolutestartTime","Relativeto");
}
migrateList.add(migrateHash);
hmap.put("migrate",migrateList);
migrateCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterException("Migrate");
}
;
crPlMigrateParams throws ArchiveSystemApplicationException
: setMgCopyName
| setMgdestPool
| setMgAbsstartTime
| setMgRelDuration
| setMgRelativeTo
| setError
;
setMgCopyName throws ArchiveSystemApplicationException
:
COPYNAME (WS)? copyNo:ALPHANUM
{
String cpynum = copyNo.getText().trim();
if( mgSrcCopyNoCount == 1)
{
throw new ParameterRepeatedException
("Migrate::CopyName");
}
if((cpynum.equals("="))||(cpynum.equals("")))
{
throw new MissingParameterValueException
("Migrate::CopyName");
}
if(!(isStringValid(cpynum)))
{
throw new InvalidParameterValueException
("Migrate::CopyName");
}
migrateHash.put("copyname",cpynum);
mgSrcCopyNoCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("Migrate::CopyName");
}
;
setMgdestPool throws ArchiveSystemApplicationException
:
DESTINATIONPOOL (WS)? mgDestPool:ALPHANUM
{
if( mgDestinationPoolCount ==1 )
{
throw new ParameterRepeatedException
("Migrate::DestinationPool");
}
String destPool= mgDestPool.getText().trim();
if ((destPool.equals("="))||(destPool.equals("")))
{
throw new MissingParameterValueException
("Migrate::destination pool");
}
if (!isStringValid(destPool))
{
throw new InvalidParameterValueException
("Migrate::destination pool");
}
migrateHash.put("destinationpool", destPool);
mgDestinationPoolCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("Migrate::destination pool");
}
;
setMgAbsstartTime throws ArchiveSystemApplicationException
:
ABSOLUTESTARTTIME (WS)? sttime:ALPHANUM
{
if( mgAbsStTime == 1)
{
throw new ParameterRepeatedException
("Migrate::absolutestarttime");
}
String strtTime = sttime.getText().trim();
if((strtTime.equals("="))||(strtTime.equals("")))
{
throw new MissingParameterValueException
("Migrate::starttime");
}
if(!(isDateValid(strtTime)))
{
throw new InvalidParameterValueException
("Migrate::starttime");
}
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, day, hours, min, 0);
Date dateFormat = calendar.getTime();
migrateHash.put("absolutestarttime",dateFormat);
mgAbsStTime++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("Migrate::starttime");
}
;
setMgRelDuration throws ArchiveSystemApplicationException
:
RELATIVEDURATION (WS)? sttime:ALPHANUM
{
if( mgRelDur == 1)
{
throw new ParameterRepeatedException
("Migrate::Relativeduration");
}
String duration = sttime.getText().trim();
if((duration.equals("="))||(duration==null))
{
throw new MissingParameterValueException
("Migrate::Relativeduration");
}
if(!(isRelativeTimeValid(duration)))
{
throw new InvalidParameterValueException
("Migrate::Relativeduration");
}
migrateHash.put("relativestarttime",duration);
mgRelDur++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("Migrate::Relativeduration");
}
;
setMgRelativeTo throws ArchiveSystemApplicationException
:
RELATIVESTARTTIMETO (WS)? mgrelto:ALPHANUM
{
if( mgRelTo == 1)
{
throw new ParameterRepeatedException
("Migrate::relativeto");
}
String relTo= mgrelto.getText().trim();
if ((relTo.equals("="))||(relTo.equals("")))
{
throw new MissingParameterValueException("relativeto");
}
if (!isRelStartTimeValid(relTo))
{
throw new InvalidParameterValueException("relativeto");
}
if(relTo.equalsIgnoreCase("creation")) {
migrateHash.put("relativestarttimeto",new Integer(1));
}
else if(relTo.equalsIgnoreCase("modification")) {
migrateHash.put("relativestarttimeto",new Integer(2));
}
else if(relTo.equalsIgnoreCase("LastAccess")) {
migrateHash.put("relativestarttimeto",new Integer(3));
}
mgRelTo++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException("relativeto");
}
;
setLog throws ArchiveSystemApplicationException
{
logMap = new HashMap();
lgReadAccessCount = 0;
lgintdatastrgCount = 0;
lgdupDataDetCount =0;
lgDataAlterCount = 0;
}
:
LOG (WS)? (OPAREN) (WS crPlyLogParams)* (WS)? (CPAREN)
{
if(logSectionCount == 1)
{
throw new ParameterRepeatedException("log");
}
if(lgReadAccessCount ==0 )
{
throw new MissingParameterValueException
("successfullReadAccess ");
}
if(lgintdatastrgCount ==0 )
{
throw new MissingParameterValueException
("initialDataStorageActions ");
}
if(lgdupDataDetCount ==0 )
{
throw new MissingParameterValueException
("duplicateDataDetectionsActions ");
}
if(lgDataAlterCount ==0 )
{
throw new MissingParameterValueException
("successfullDataAlterations ");
}
logSectionCount++;
hmap.put("log",logMap);
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterException("log");
}
;
crPlyLogParams throws ArchiveSystemApplicationException
: setlgReadAccess
| setlgInitialDataStorage
| setlgDuplicateDetection
| setlgSuccessfulDataAlterations
| setError
;
setlgReadAccess throws ArchiveSystemApplicationException
:
SUCCESSFULLREADACCESS (WS)? a:ALPHANUM
{
if( lgReadAccessCount == 1)
{
throw new ParameterRepeatedException
("successfullReadAccess");
}
String readAccess = a.getText().trim();
if (readAccess.equals("="))
{
throw new MissingParameterValueException
("successfullReadAccess");
}
if (!isBoolValid(readAccess))
{
throw new InvalidParameterValueException
("successfullReadAccess");
}
logMap.put("successfullreadaccess",readAccess);
lgReadAccessCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("successfullReadAccess");
}
;
setlgInitialDataStorage throws ArchiveSystemApplicationException
:
INITIALDATASTORAGEACTIONS (WS)? a:ALPHANUM
{
if( lgintdatastrgCount == 1)
{
throw new ParameterRepeatedException
("initialDataStorageActions");
}
String storageName = a.getText().trim();
if ((storageName.equals("="))||(storageName.equals("")))
{
throw new MissingParameterValueException
("initialDataStorageActions");
}
if (!isBoolValid(storageName))
{
throw new InvalidParameterValueException
("initialDataStorageActions");
}
logMap.put("initialdatastorageactions", storageName);
lgintdatastrgCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("initialDataStorageActions");
}
;
setlgDuplicateDetection throws ArchiveSystemApplicationException
:
DUPLICATEDATADETECTIONSACTIONS (WS)? a:ALPHANUM
{
if( lgdupDataDetCount == 1)
{
throw new ParameterRepeatedException
("duplicateDataDetectionsActions");
}
String dupDetect = a.getText().trim();
if( (dupDetect.equals("="))|| (dupDetect.equals("")))
{
throw new MissingParameterValueException
("duplicateDataDetectionsActions");
}
if (!isBoolValid(dupDetect))
{
throw new InvalidParameterValueException
("duplicateDataDetectionsActions");
}
logMap.put("duplicatedetectionactions", dupDetect);
lgdupDataDetCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("duplicateDataDetectionsActions");
}
;
setlgSuccessfulDataAlterations throws
ArchiveSystemApplicationException
:
SUCCESSFULLDATAALTERATIONS (WS)? a:ALPHANUM
{
if( lgDataAlterCount == 1)
{
throw new ParameterRepeatedException
("successfullDataAlterations");
}
String dataAlter = a.getText().trim();
if ((dataAlter.equals("="))||(dataAlter.equals("")))
{
throw new MissingParameterValueException
("successfullDataAlterations");
}
if (!isBoolValid(dataAlter))
{
throw new InvalidParameterValueException
("successfullDataAlterations");
}
logMap.put("successfuldataalterations", dataAlter);
lgDataAlterCount++;
}
exception
catch [NoViableAltException nvae]
{
throw new MissingParameterValueException
("successfullDataAlterations");
}
;
setError throws ArchiveSystemApplicationException
:
a:ALPHANUM
{
if (true)
{
throw new UnknownParameterException(a.getText().trim());
}
}
;
/*------------------------------------------------------------------*/
/* Method that validates the input to a boolean vlaue */
/* */
/* @param inputStr, holds the user input data. */
/* @return bRetVal, holds whether the data is valid or not. */
/*------------------------------------------------------------------*/
isBoolValid[String inputStr] returns [boolean bRetVal = true]
:
{
String patternMatch = "['y','e','s','n','o']";
if (inputStr.equalsIgnoreCase("yes")||
(inputStr.equalsIgnoreCase("no")))
{
if (inputStr.length() > maxLength)
{
bRetVal = false;
}
}
else
{
bRetVal = false;
}
}
;
/*------------------------------------------------------------------*/
/* Method that validates the input to a valid string */
/* */
/* @param inputStr, holds the user input data. */
/* @return bRetVal, holds whether the data is valid or not. */
/*------------------------------------------------------------------*/
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;
}
}
;
/*------------------------------------------------------------------*/
/* Method that validates the input to an int */
/* */
/* @param inputStr, holds the user input data. */
/* @return bRetVal, holds whether the data is valid or not. */
/*------------------------------------------------------------------*/
isIntValid[String inputStr] returns [boolean bRetVal = true]
:
{
String patternMatch = "[\\d]*";
if (!inputStr.matches(patternMatch))
{
bRetVal = false;
}
}
;
/*------------------------------------------------------------------*/
/* Method that validates the date and time for the parameters */
/*
*/
/* */
/* @param inputStr, holds the user input data. */
/* @return bRetVal, holds whether the data is valid or not. */
/*------------------------------------------------------------------*/
isDateValid[String inputStr] returns [boolean bRetVal = true]
:
{
String patternMatch = "[\\d:]*";
if (!inputStr.matches(patternMatch))
{
bRetVal = false;
}
if (bRetVal)
{
StringTokenizer startTime = new StringTokenizer
(inputStr, ":");
if (startTime.countTokens() != 5)
{
bRetVal = false;
}
else
{
year = Integer.parseInt((String) startTime.nextToken
());
month = Integer.parseInt((String) startTime.nextToken
());
day = Integer.parseInt((String) startTime.nextToken
());
hours = Integer.parseInt((String) startTime.nextToken
());
min = Integer.parseInt((String) startTime.nextToken
());
if ((year < 2003) || (year > 9999) ||
(month < 1) || (month > 12) ||
(day < 1) || (day > 31)||(hours < 0) || (hours >
23) ||
(min < 0) || (min > 59))
{
bRetVal = false;
}
}
}
}
;
/*------------------------------------------------------------
------*/
/* Method that validates the retention time
*/
/*
*/
/*
*/
/* @param inputStr, holds the user input
data. */
/* @return bRetVal, holds whether the data is valid or
not. */
/*------------------------------------------------------------
------*/
isRelativeTimeValid[String inputStr] returns [boolean bRetVal
= true]
:
{
String patternMatch = "[\\d:]*[d,m,y]";
if (!inputStr.matches(patternMatch))
{
bRetVal = false;
}
}
;
/*------------------------------------------------------------
------*/
/* Method that validates the relative start time to
*/
/*
*/
/*
*/
/* @param inputStr, holds the user input
data. */
/* @return bRetVal, holds whether the data is valid or
not. */
/*------------------------------------------------------------
------*/
isRelStartTimeValid[String inputStr] returns [boolean bRetVal
= true]
:
{
if (!(
(inputStr.equalsIgnoreCase("creation"))
||
(inputStr.equalsIgnoreCase
("modification"))||
(inputStr.equalsIgnoreCase
("LastAccess"))
)) {
bRetVal = false;
}
}
;
/**
* A Lexer class representing lexer for show policy cmd.
*/
class CreatePolicyLexer extends Lexer;
options
{
k = 20;
caseSensitiveLiterals = false;
caseSensitive = false;
charVocabulary = ' '..'~';
}
// Definitions of verbs
CREATE : "create";
// Definitions of objects
POLICY : "policy";
//def of params
POLICYNAME : "policyname";
POLICYDESCR : "policydescr";
CREATECOPY :"createcopy";
COPYNAME :"copyname";
DESTINATIONPOOL: "destinationpool";
STARTTIME :"starttime";
ABSOLUTESTARTTIME :"absolutestarttime";
ABSOLUTERETENTIONTIME:"absoluteretention"('t'('i'('m'('e')?)?)?)?;
MIGRATE :"migrate";
RELATIVESTARTTIMETO :"relativestarttimeto";
RELATIVEDURATION: "relativedura"('t'('i'('o'('n')?)?)?)?;
LOG :"log";
SUCCESSFULLREADACCESS :"successfullreadaccess";
RETENTIONDURATION : "retentionduration";
INITIALDATASTORAGEACTIONS :"initialdatastorage"('a'('c'('t'('i'('o'('n
'('s')?)?)?)?)?)?)?;
SUCCESSFULLDATAALTERATIONS:"successfulldata"('a'('l'('t'('e'('r'('a'('
t'('i'('o'('n'('s')?)?)?)?)?)?)?)?)?)?)?;
DUPLICATEDATADETECTIONSACTIONS
:"duplicatedata"('d'('e'('t'('e'('c'('t'('i'('o'('n'('s'('a'('
c'('t'('i'('o'('n'('s')?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?)?;
OPAREN: "(";
CPAREN : ")";
WS : (' ' | '\t')+;
NEWLINE : '\n';
protected
ALPHANUM options { testLiterals = false; }
: ('=') => '='! (WS)? (~(' ' | '\t' | '\n'))+
| (WS)? (~(' ' | '\t' | '\n'))+
;
the output obtained is :
CreatePolicy.g:244: warning:nondeterminism upon
CreatePolicy.g:244: k==1:WS
CreatePolicy.g:244: k==2:ALPHANUM
CreatePolicy.g:244: k==3:WS,NEWLINE
CreatePolicy.g:244: k==4:EOF,WS,ALPHANUM,CREATECOPY,MIGRATE,LOG
CreatePolicy.g:244: k==5:EOF,WS,NEWLINE,ALPHANUM,OPAREN
CreatePolicy.g:244:
k==6:EOF,WS,NEWLINE,ALPHANUM,CREATECOPY,OPAREN,CPAREN,MI
GRATE,LOG
CreatePolicy.g:244:
k==7:EOF,WS,NEWLINE,ALPHANUM,CREATECOPY,OPAREN,CPAREN,CO
PYNAME,DESTINATIONPOOL,RETENTIONDURATION,STARTTIME,ABSOLUTERETENTIONTI
ME,MIGRATE
,ABSOLUTESTARTTIME,RELATIVEDURATION,RELATIVESTARTTIMETO,LOG,SUCCESSFUL
LREADACCES
S,INITIALDATASTORAGEACTIONS,DUPLICATEDATADETECTIONSACTIONS,SUCCESSFULL
DATAALTERA
TIONS
CreatePolicy.g:244:
k==8:EOF,WS,NEWLINE,ALPHANUM,CREATECOPY,OPAREN,CPAREN,CO
PYNAME,DESTINATIONPOOL,RETENTIONDURATION,STARTTIME,ABSOLUTERETENTIONTI
ME,MIGRATE
,ABSOLUTESTARTTIME,RELATIVEDURATION,RELATIVESTARTTIMETO,LOG,SUCCESSFUL
LREADACCES
S,INITIALDATASTORAGEACTIONS,DUPLICATEDATADETECTIONSACTIONS,SUCCESSFULL
DATAALTERA
TIONS
CreatePolicy.g:244:
k==9:EOF,WS,NEWLINE,ALPHANUM,CREATECOPY,OPAREN,CPAREN,CO
PYNAME,DESTINATIONPOOL,RETENTIONDURATION,STARTTIME,ABSOLUTERETENTIONTI
ME,MIGRATE
,ABSOLUTESTARTTIME,RELATIVEDURATION,RELATIVESTARTTIMETO,LOG,SUCCESSFUL
LREADACCES
S,INITIALDATASTORAGEACTIONS,DUPLICATEDATADETECTIONSACTIONS,SUCCESSFULL
DATAALTERA
TIONS
CreatePolicy.g:244: between alt 1 and exit branch of block
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