Vidyashree Rama
Committed by Gerrit Code Review

string issue fix for few yang construct like config, mandatory + allowing yang c…

…onstructs as identifers and string

Change-Id: I8dd01dc60d280a843b0a485681caa6bfcac013c2
Showing 16 changed files with 717 additions and 153 deletions
......@@ -1178,22 +1178,6 @@ public interface GeneratedYangListener extends ParseTreeListener {
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* maxValueArgument.
*
* @param currentContext current context in the parsed tree
*/
void enterMaxValueArgument(GeneratedYangParser.MaxValueArgumentContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* maxValueArgument.
*
* @param currentContext current context in the parsed tree
*/
void exitMaxValueArgument(GeneratedYangParser.MaxValueArgumentContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* valueStatement.
*
* @param currentContext current context in the parsed tree
......@@ -1720,6 +1704,37 @@ public interface GeneratedYangListener extends ParseTreeListener {
*/
void exitIdentifier(GeneratedYangParser.IdentifierContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* version.
*
* @param currentContext current context in the parsed tree
*/
void enterVersion(GeneratedYangParser.VersionContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* version.
*
* @param currentContext current context in the parsed tree
*/
void exitVersion(GeneratedYangParser.VersionContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* range.
*
* @param currentContext current context in the parsed tree
*/
void enterRange(GeneratedYangParser.RangeContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* range.
*
* @param currentContext current context in the parsed tree
*/
void exitRange(GeneratedYangParser.RangeContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
......@@ -1736,4 +1751,244 @@ public interface GeneratedYangListener extends ParseTreeListener {
* @param currentContext current context in the parsed tree
*/
void exitDateArgumentString(GeneratedYangParser.DateArgumentStringContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* length.
*
* @param currentContext current context in the parsed tree
*/
void enterLength(GeneratedYangParser.LengthContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* length.
*
* @param currentContext current context in the parsed tree
*/
void exitLength(GeneratedYangParser.LengthContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* path.
*
* @param currentContext current context in the parsed tree
*/
void enterPath(GeneratedYangParser.PathContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* path.
*
* @param currentContext current context in the parsed tree
*/
void exitPath(GeneratedYangParser.PathContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* position.
*
* @param currentContext current context in the parsed tree
*/
void enterPosition(GeneratedYangParser.PositionContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* position.
*
* @param currentContext current context in the parsed tree
*/
void exitPosition(GeneratedYangParser.PositionContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* status.
*
* @param currentContext current context in the parsed tree
*/
void enterStatus(GeneratedYangParser.StatusContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* status.
*
* @param currentContext current context in the parsed tree
*/
void exitStatus(GeneratedYangParser.StatusContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* config.
*
* @param currentContext current context in the parsed tree
*/
void enterConfig(GeneratedYangParser.ConfigContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* config.
*
* @param currentContext current context in the parsed tree
*/
void exitConfig(GeneratedYangParser.ConfigContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* mandatory.
*
* @param currentContext current context in the parsed tree
*/
void enterMandatory(GeneratedYangParser.MandatoryContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* mandatory.
*
* @param currentContext current context in the parsed tree
*/
void exitMandatory(GeneratedYangParser.MandatoryContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* ordered-by.
*
* @param currentContext current context in the parsed tree
*/
void enterOrderedBy(GeneratedYangParser.OrderedByContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* ordered-by.
*
* @param currentContext current context in the parsed tree
*/
void exitOrderedBy(GeneratedYangParser.OrderedByContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* min elements value.
*
* @param currentContext current context in the parsed tree
*/
void enterMinValue(GeneratedYangParser.MinValueContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* min elements value.
*
* @param currentContext current context in the parsed tree
*/
void exitMinValue(GeneratedYangParser.MinValueContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* max elements value.
*
* @param currentContext current context in the parsed tree
*/
void enterMaxValue(GeneratedYangParser.MaxValueContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* max elements value.
*
* @param currentContext current context in the parsed tree
*/
void exitMaxValue(GeneratedYangParser.MaxValueContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* key.
*
* @param currentContext current context in the parsed tree
*/
void enterKey(GeneratedYangParser.KeyContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* key.
*
* @param currentContext current context in the parsed tree
*/
void exitKey(GeneratedYangParser.KeyContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* unique.
*
* @param currentContext current context in the parsed tree
*/
void enterUnique(GeneratedYangParser.UniqueContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* unique.
*
* @param currentContext current context in the parsed tree
*/
void exitUnique(GeneratedYangParser.UniqueContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* refine.
*
* @param currentContext current context in the parsed tree
*/
void enterRefine(GeneratedYangParser.RefineContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* refine.
*
* @param currentContext current context in the parsed tree
*/
void exitRefine(GeneratedYangParser.RefineContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* augment.
*
* @param currentContext current context in the parsed tree
*/
void enterAugment(GeneratedYangParser.AugmentContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* augment.
*
* @param currentContext current context in the parsed tree
*/
void exitAugment(GeneratedYangParser.AugmentContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* deviation.
*
* @param currentContext current context in the parsed tree
*/
void enterDeviation(GeneratedYangParser.DeviationContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* deviation.
*
* @param currentContext current context in the parsed tree
*/
void exitDeviation(GeneratedYangParser.DeviationContext currentContext);
/**
* Enter a parse tree produced by GeneratedYangParser for grammar rule
* yang construct.
*
* @param currentContext current context in the parsed tree
*/
void enterYangConstruct(GeneratedYangParser.YangConstructContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
* yang construct.
*
* @param currentContext current context in the parsed tree
*/
void exitYangConstruct(GeneratedYangParser.YangConstructContext currentContext);
}
......
......@@ -833,16 +833,6 @@ public class TreeWalkListener implements GeneratedYangListener {
}
@Override
public void enterMaxValueArgument(GeneratedYangParser.MaxValueArgumentContext ctx) {
// TODO: implement the method.
}
@Override
public void exitMaxValueArgument(GeneratedYangParser.MaxValueArgumentContext ctx) {
// TODO: implement the method.
}
@Override
public void enterValueStatement(GeneratedYangParser.ValueStatementContext ctx) {
ValueListener.processValueEntry(this, ctx);
}
......@@ -1183,6 +1173,176 @@ public class TreeWalkListener implements GeneratedYangListener {
}
@Override
public void enterRange(GeneratedYangParser.RangeContext ctx) {
// TODO: implement the method.
}
@Override
public void exitRange(GeneratedYangParser.RangeContext ctx) {
// TODO: implement the method.
}
@Override
public void enterLength(GeneratedYangParser.LengthContext ctx) {
// TODO: implement the method.
}
@Override
public void exitLength(GeneratedYangParser.LengthContext ctx) {
// TODO: implement the method.
}
@Override
public void enterPath(GeneratedYangParser.PathContext ctx) {
// TODO: implement the method.
}
@Override
public void exitPath(GeneratedYangParser.PathContext ctx) {
// TODO: implement the method.
}
@Override
public void enterPosition(GeneratedYangParser.PositionContext ctx) {
// TODO: implement the method.
}
@Override
public void exitPosition(GeneratedYangParser.PositionContext ctx) {
// TODO: implement the method.
}
@Override
public void enterStatus(GeneratedYangParser.StatusContext ctx) {
// TODO: implement the method.
}
@Override
public void exitStatus(GeneratedYangParser.StatusContext ctx) {
// TODO: implement the method.
}
@Override
public void enterConfig(GeneratedYangParser.ConfigContext ctx) {
// TODO: implement the method.
}
@Override
public void exitConfig(GeneratedYangParser.ConfigContext ctx) {
// TODO: implement the method.
}
@Override
public void enterMandatory(GeneratedYangParser.MandatoryContext ctx) {
// TODO: implement the method.
}
@Override
public void exitMandatory(GeneratedYangParser.MandatoryContext ctx) {
// TODO: implement the method.
}
@Override
public void enterOrderedBy(GeneratedYangParser.OrderedByContext ctx) {
// TODO: implement the method.
}
@Override
public void exitOrderedBy(GeneratedYangParser.OrderedByContext ctx) {
// TODO: implement the method.
}
@Override
public void enterMinValue(GeneratedYangParser.MinValueContext ctx) {
// TODO: implement the method.
}
@Override
public void exitMinValue(GeneratedYangParser.MinValueContext ctx) {
// TODO: implement the method.
}
@Override
public void enterMaxValue(GeneratedYangParser.MaxValueContext ctx) {
// TODO: implement the method.
}
@Override
public void exitMaxValue(GeneratedYangParser.MaxValueContext ctx) {
// TODO: implement the method.
}
@Override
public void enterKey(GeneratedYangParser.KeyContext ctx) {
// TODO: implement the method.
}
@Override
public void exitKey(GeneratedYangParser.KeyContext ctx) {
// TODO: implement the method.
}
@Override
public void enterUnique(GeneratedYangParser.UniqueContext ctx) {
// TODO: implement the method.
}
@Override
public void exitUnique(GeneratedYangParser.UniqueContext ctx) {
// TODO: implement the method.
}
@Override
public void enterRefine(GeneratedYangParser.RefineContext ctx) {
// TODO: implement the method.
}
@Override
public void exitRefine(GeneratedYangParser.RefineContext ctx) {
// TODO: implement the method.
}
@Override
public void enterAugment(GeneratedYangParser.AugmentContext ctx) {
// TODO: implement the method.
}
@Override
public void exitAugment(GeneratedYangParser.AugmentContext ctx) {
// TODO: implement the method.
}
@Override
public void enterDeviation(GeneratedYangParser.DeviationContext ctx) {
// TODO: implement the method.
}
@Override
public void exitDeviation(GeneratedYangParser.DeviationContext ctx) {
// TODO: implement the method.
}
@Override
public void enterYangConstruct(GeneratedYangParser.YangConstructContext ctx) {
// TODO: implement the method.
}
@Override
public void exitYangConstruct(GeneratedYangParser.YangConstructContext ctx) {
// TODO: implement the method.
}
@Override
public void enterVersion(GeneratedYangParser.VersionContext ctx) {
// TODO: implement the method.
}
@Override
public void exitVersion(GeneratedYangParser.VersionContext ctx) {
// TODO: implement the method.
}
@Override
public void visitTerminal(TerminalNode terminalNode) {
// TODO: implement the method.
}
......
......@@ -25,6 +25,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidBooleanValue;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
......@@ -42,7 +43,8 @@ import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
* config-arg = true-keyword / false-keyword
*
* ANTLR grammar rule
* configStatement : CONFIG_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;
* configStatement : CONFIG_KEYWORD config STMTEND;
* config : string;
*/
/**
......@@ -66,14 +68,11 @@ public final class ConfigListener {
*/
public static void processConfigEntry(TreeWalkListener listener,
GeneratedYangParser.ConfigStatementContext ctx) {
boolean isConfig = false;
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONFIG_DATA, "", ENTRY);
if (ctx.TRUE_KEYWORD() != null) {
isConfig = true;
}
boolean isConfig = getValidBooleanValue(ctx.config().getText(), CONFIG_DATA, ctx);
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getYangConstructType()) {
......
......@@ -24,6 +24,7 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
......@@ -39,7 +40,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
* key-stmt = key-keyword sep key-arg-str stmtend
*
* ANTLR grammar rule
* keyStatement : KEY_KEYWORD string STMTEND;
* keyStatement : KEY_KEYWORD key STMTEND;
* key : string;
*/
/**
......@@ -66,12 +68,12 @@ public final class KeyListener {
GeneratedYangParser.KeyStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.string().getText(), ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, KEY_DATA, ctx.key().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
if (listener.getParsedDataStack().peek() instanceof YangList) {
YangList yangList = (YangList) tmpData;
String tmpKeyValue = ctx.string().getText().replace("\"", "");
String tmpKeyValue = removeQuotesAndHandleConcat(ctx.key().getText());
if (tmpKeyValue.contains(" ")) {
String[] keyValues = tmpKeyValue.split(" ");
for (String keyValue : keyValues) {
......@@ -79,7 +81,7 @@ public final class KeyListener {
yangList.addKey(keyValue);
} catch (DataModelException e) {
throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, KEY_DATA,
ctx.string().getText(), ENTRY, e.getMessage()));
ctx.key().getText(), ENTRY, e.getMessage()));
}
}
} else {
......@@ -87,11 +89,11 @@ public final class KeyListener {
yangList.addKey(tmpKeyValue);
} catch (DataModelException e) {
throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, KEY_DATA,
ctx.string().getText(), ENTRY, e.getMessage()));
ctx.key().getText(), ENTRY, e.getMessage()));
}
}
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.string().getText(),
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, KEY_DATA, ctx.key().getText(),
ENTRY));
}
}
......
......@@ -22,6 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidBooleanValue;
import static org.onosproject.yangutils.utils.YangConstructType.MANDATORY_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
......@@ -42,7 +43,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
* mandatory-arg = true-keyword / false-keyword
*
* ANTLR grammar rule
* mandatoryStatement : MANDATORY_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;
* mandatoryStatement : MANDATORY_KEYWORD mandatory STMTEND;
* mandatory : string;
*/
/**
......@@ -71,15 +73,13 @@ public final class MandatoryListener {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY);
boolean isMandatory = getValidBooleanValue(ctx.mandatory().getText(), MANDATORY_DATA, ctx);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpNode;
if (ctx.TRUE_KEYWORD() != null) {
leaf.setMandatory(true);
} else {
leaf.setMandatory(false);
}
leaf.setMandatory(isMandatory);
break;
case CHOICE_DATA: // TODO
break;
......
......@@ -22,11 +22,13 @@ import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA;
......@@ -40,7 +42,8 @@ import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA
* max-value-arg >
*
* ANTLR grammar rule
* maxElementsStatement : MAX_ELEMENTS_KEYWORD maxValueArgument STMTEND;
* maxElementsStatement : MAX_ELEMENTS_KEYWORD maxValue STMTEND;
* maxValue : string;
*/
/**
......@@ -50,6 +53,9 @@ import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA
*/
public final class MaxElementsListener {
private static final String POSITIVE_INTEGER_PATTERN = "[1-9][0-9]*";
private static final String UNBOUNDED_KEYWORD = "unbounded";
/**
* Creates a new max-elements listener.
*/
......@@ -65,16 +71,11 @@ public final class MaxElementsListener {
*/
public static void processMaxElementsEntry(TreeWalkListener listener,
GeneratedYangParser.MaxElementsStatementContext ctx) {
int maxElementsValue;
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, MAX_ELEMENT_DATA, "", ENTRY);
if (ctx.maxValueArgument().UNBOUNDED_KEYWORD() != null) {
maxElementsValue = Integer.MAX_VALUE;
} else {
maxElementsValue = Integer.parseInt(ctx.maxValueArgument().INTEGER().getText());
}
int maxElementsValue = getValidMaxElementValue(ctx);
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getYangConstructType()) {
......@@ -90,4 +91,31 @@ public final class MaxElementsListener {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MAX_ELEMENT_DATA, "", ENTRY));
}
}
/**
* Validates max element value and returns the value from context.
*
* @param ctx context object of the grammar rule
* @return max element's value
*/
private static int getValidMaxElementValue(GeneratedYangParser.MaxElementsStatementContext ctx) {
int maxElementsValue;
String value = removeQuotesAndHandleConcat(ctx.maxValue().getText());
if (value.equals(UNBOUNDED_KEYWORD)) {
maxElementsValue = Integer.MAX_VALUE;
} else if (value.matches(POSITIVE_INTEGER_PATTERN)) {
maxElementsValue = Integer.parseInt(value);
} else {
ParserException parserException = new ParserException("YANG file error : " +
YangConstructType.getYangConstructType(MAX_ELEMENT_DATA) + " value " + value + " is not " +
"valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
return maxElementsValue;
}
}
\ No newline at end of file
......
......@@ -23,6 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidNonNegativeIntegerValue;
import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
......@@ -41,7 +42,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
* min-value-arg = non-negative-integer-value
*
* ANTLR grammar rule
* minElementsStatement : MIN_ELEMENTS_KEYWORD INTEGER STMTEND;
* minElementsStatement : MIN_ELEMENTS_KEYWORD minValue STMTEND;
* minValue : string;
*/
/**
......@@ -68,21 +70,23 @@ public final class MinElementsListener {
GeneratedYangParser.MinElementsStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.minValue().getText(), ENTRY);
int minElementValue = getValidNonNegativeIntegerValue(ctx.minValue().getText(), MIN_ELEMENT_DATA, ctx);
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getYangConstructType()) {
case LEAF_LIST_DATA:
YangLeafList leafList = (YangLeafList) tmpData;
leafList.setMinElements(Integer.parseInt(ctx.INTEGER().getText()));
leafList.setMinElements(minElementValue);
break;
case LIST_DATA:
YangList yangList = (YangList) tmpData;
yangList.setMinElements(Integer.parseInt(ctx.INTEGER().getText()));
yangList.setMinElements(minElementValue);
break;
default:
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MIN_ELEMENT_DATA,
ctx.INTEGER().getText(), ENTRY));
ctx.minValue().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -30,7 +30,8 @@ package org.onosproject.yangutils.parser.impl.listeners;
* zero-integer-value = 1*DIGIT
*
* ANTLR grammar rule
* positionStatement : POSITION_KEYWORD string STMTEND;
* positionStatement : POSITION_KEYWORD position STMTEND;
* position : string;
*/
import org.onosproject.yangutils.datamodel.YangBit;
......@@ -44,7 +45,7 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLoc
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidNonNegativeIntegerValue;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.POSITION_DATA;
......@@ -54,9 +55,6 @@ import static org.onosproject.yangutils.utils.YangConstructType.POSITION_DATA;
*/
public final class PositionListener {
// Exact message in case position is invalid.
private static String errMsg;
/**
* Creates a new position listener.
*/
......@@ -74,27 +72,20 @@ public final class PositionListener {
GeneratedYangParser.PositionStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.string().getText(), ENTRY);
String position = removeQuotesAndHandleConcat(ctx.string().getText());
checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.position().getText(), ENTRY);
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getYangConstructType()) {
case BIT_DATA: {
YangBit bitNode = (YangBit) tmpNode;
if (!isBitPositionValid(listener, ctx, position)) {
ParserException parserException = new ParserException(errMsg);
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
bitNode.setPosition(Integer.valueOf(position));
int positionValue = getValidBitPosition(listener, ctx);
bitNode.setPosition(positionValue);
break;
}
default:
throw new ParserException(
constructListenerErrorMessage(INVALID_HOLDER, POSITION_DATA, ctx.string().getText(), ENTRY));
constructListenerErrorMessage(INVALID_HOLDER, POSITION_DATA, ctx.position().getText(), ENTRY));
}
}
......@@ -103,39 +94,38 @@ public final class PositionListener {
*
* @param listener Listener's object
* @param ctx context object of the grammar rule
* @return validation result
* @return position value
*/
private static boolean isBitPositionValid(TreeWalkListener listener,
GeneratedYangParser.PositionStatementContext ctx, String position) {
private static int getValidBitPosition(TreeWalkListener listener,
GeneratedYangParser.PositionStatementContext ctx) {
Parsable bitNode = listener.getParsedDataStack().pop();
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.string().getText(), ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, POSITION_DATA, ctx.position().getText(), ENTRY);
if (Integer.valueOf(position) < 0) {
errMsg = "YANG file error: Negative value of position is invalid.";
listener.getParsedDataStack().push(bitNode);
return false;
}
int positionValue = getValidNonNegativeIntegerValue(ctx.position().getText(), POSITION_DATA, ctx);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getYangConstructType()) {
case BITS_DATA: {
YangBits yangBits = (YangBits) tmpNode;
for (YangBit curBit : yangBits.getBitSet()) {
if (Integer.valueOf(position) == curBit.getPosition()) {
errMsg = "YANG file error: Duplicate value of position is invalid.";
if (positionValue == curBit.getPosition()) {
listener.getParsedDataStack().push(bitNode);
return false;
ParserException parserException = new ParserException("YANG file error: Duplicate value of " +
"position is invalid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
}
listener.getParsedDataStack().push(bitNode);
return true;
return positionValue;
}
default:
listener.getParsedDataStack().push(bitNode);
throw new ParserException(
constructListenerErrorMessage(INVALID_HOLDER, POSITION_DATA, ctx.string().getText(), ENTRY));
constructListenerErrorMessage(INVALID_HOLDER, POSITION_DATA, ctx.position().getText(), ENTRY));
}
}
}
\ No newline at end of file
......
......@@ -23,10 +23,12 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CONTENT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
......@@ -51,6 +53,10 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
*/
public final class StatusListener {
private static final String CURRENT_KEYWORD = "current";
private static final String DEPRECATED_KEYWORD = "deprecated";
private static final String OBSOLETE_KEYWORD = "obsolete";
/**
* Creates a new status listener.
*/
......@@ -67,18 +73,11 @@ public final class StatusListener {
*/
public static void processStatusEntry(TreeWalkListener listener,
GeneratedYangParser.StatusStatementContext ctx) {
YangStatusType status;
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, STATUS_DATA, "", ENTRY);
if (ctx.CURRENT_KEYWORD() != null) {
status = YangStatusType.CURRENT;
} else if (ctx.DEPRECATED_KEYWORD() != null) {
status = YangStatusType.DEPRECATED;
} else {
status = YangStatusType.OBSOLETE;
}
YangStatusType status = getValidStatus(ctx);
Parsable tmpData = listener.getParsedDataStack().peek();
if (tmpData instanceof YangStatus) {
......@@ -88,4 +87,28 @@ public final class StatusListener {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, STATUS_DATA, "", ENTRY));
}
}
/**
* Validates status value and returns the value from context.
*
* @param ctx context object of the grammar rule
* @return status current/deprecated/obsolete
*/
private static YangStatusType getValidStatus(GeneratedYangParser.StatusStatementContext ctx) {
YangStatusType status;
String value = removeQuotesAndHandleConcat(ctx.status().getText());
if (value.equals(CURRENT_KEYWORD)) {
status = YangStatusType.CURRENT;
} else if (value.equals(DEPRECATED_KEYWORD)) {
status = YangStatusType.DEPRECATED;
} else if (value.equals(OBSOLETE_KEYWORD)) {
status = YangStatusType.OBSOLETE;
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_CONTENT, STATUS_DATA, value, ENTRY));
}
return status;
}
}
\ No newline at end of file
......
......@@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidVersion;
import static org.onosproject.yangutils.utils.YangConstructType.VERSION_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
......@@ -60,7 +60,8 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
* submodule_header_statement : yang_version_stmt? belongs_to_stmt
* | belongs_to_stmt yang_version_stmt?
* ;
* yang_version_stmt : YANG_VERSION_KEYWORD string STMTEND;
* yang_version_stmt : YANG_VERSION_KEYWORD version STMTEND;
* version : string;
*/
/**
......@@ -86,42 +87,26 @@ public final class VersionListener {
GeneratedYangParser.YangVersionStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, VERSION_DATA, ctx.string().getText(), ENTRY);
checkStackIsNotEmpty(listener, MISSING_HOLDER, VERSION_DATA, ctx.version().getText(), ENTRY);
String version = removeQuotesAndHandleConcat(ctx.string().getText());
if (!isVersionValid(Integer.valueOf(version))) {
ParserException parserException = new ParserException("YANG file error: Input version not supported");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
byte version = getValidVersion(ctx);
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setVersion((byte) 1);
module.setVersion(version);
break;
}
case SUB_MODULE_DATA: {
YangSubModule subModule = (YangSubModule) tmpNode;
subModule.setVersion((byte) 1);
subModule.setVersion(version);
break;
}
default:
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, VERSION_DATA,
ctx.string().getText(), ENTRY));
ctx.version().getText(), ENTRY));
}
}
/**
* Validates whether the value of YANG version.
*
* @param version input yang version
* @return validation result
*/
private static boolean isVersionValid(Integer version) {
return version == 1;
}
}
......
......@@ -21,6 +21,8 @@ import org.antlr.v4.runtime.ParserRuleContext;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.regex.Pattern;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.parser.exceptions.ParserException;
......@@ -29,7 +31,11 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
*/
public final class ListenerUtil {
private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*");
private static final String NON_NEGATIVE_INTEGER_PATTERN = "[0-9]+";
private static final String PLUS = "+";
private static final String ONE = "1";
private static final String TRUE_KEYWORD = "true";
private static final String FALSE_KEYWORD = "false";
private static final int IDENTIFIER_LENGTH = 64;
/**
......@@ -109,4 +115,73 @@ public final class ListenerUtil {
return true;
}
/**
* Validates YANG version.
*
* @param ctx version context object of the grammar rule
* @return valid version
*/
public static byte getValidVersion(GeneratedYangParser.YangVersionStatementContext ctx) {
String value = removeQuotesAndHandleConcat(ctx.version().getText());
if (!value.equals(ONE)) {
ParserException parserException = new ParserException("YANG file error: Input version not supported");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
return Byte.valueOf(value);
}
/**
* Validates non negative integer value.
*
* @param integerValue integer to be validated
* @param yangConstruct yang construct for creating error message
* @param ctx context object of the grammar rule
* @return valid non negative integer value
*/
public static int getValidNonNegativeIntegerValue(String integerValue, YangConstructType yangConstruct,
ParserRuleContext ctx) {
String value = removeQuotesAndHandleConcat(integerValue);
if (!value.matches(NON_NEGATIVE_INTEGER_PATTERN)) {
ParserException parserException = new ParserException("YANG file error : " +
YangConstructType.getYangConstructType(yangConstruct) + " value " + value + " is not " +
"valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
return Integer.parseInt(value);
}
/**
* Validates boolean value.
*
* @param booleanValue value to be validated
* @param yangConstruct yang construct for creating error message
* @param ctx context object of the grammar rule
* @return boolean value either true or false
*/
public static boolean getValidBooleanValue(String booleanValue, YangConstructType yangConstruct,
ParserRuleContext ctx) {
String value = removeQuotesAndHandleConcat(booleanValue);
if (value.equals(TRUE_KEYWORD)) {
return true;
} else if (value.equals(FALSE_KEYWORD)) {
return false;
} else {
ParserException parserException = new ParserException("YANG file error : " +
YangConstructType.getYangConstructType(yangConstruct) + " value " + value + " is not " +
"valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
}
}
\ No newline at end of file
......
......@@ -64,7 +64,6 @@ package org.onosproject.yangutils.parser.antlrgencode;
* *(import-stmt stmtsep)
* *(include-stmt stmtsep)
*/
linkageStatements : (importStatement
| includeStatement)*;
......@@ -75,7 +74,6 @@ package org.onosproject.yangutils.parser.antlrgencode;
* [description-stmt stmtsep]
* [reference-stmt stmtsep]
*/
metaStatements : organizationStatement? contactStatement? descriptionStatement? referenceStatement?
| organizationStatement? contactStatement? referenceStatement? descriptionStatement?
| organizationStatement? descriptionStatement? contactStatement? referenceStatement?
......@@ -117,7 +115,6 @@ package org.onosproject.yangutils.parser.antlrgencode;
* notification-stmt /
* deviation-stmt) stmtsep)
*/
bodyStatements : (extensionStatement
| featureStatement
| identityStatement
......@@ -134,8 +131,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
* yang-version-stmt = yang-version-keyword sep yang-version-arg-str
* optsep stmtend
*/
yangVersionStatement : YANG_VERSION_KEYWORD string STMTEND;
yangVersionStatement : YANG_VERSION_KEYWORD version STMTEND;
/**
......@@ -455,7 +451,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
* [reference-stmt stmtsep]
* "}")
*/
rangeStatement : RANGE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);
rangeStatement : RANGE_KEYWORD range (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);
commonStatements : errorMessageStatement? errorAppTagStatement? descriptionStatement? referenceStatement?
| errorMessageStatement? errorAppTagStatement? referenceStatement? descriptionStatement?
......@@ -501,7 +497,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
* [reference-stmt stmtsep]
* "}")
*/
lengthStatement : LENGTH_KEYWORD string
lengthStatement : LENGTH_KEYWORD length
(STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);
/**
......@@ -577,7 +573,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
/**
* path-stmt = path-keyword sep path-arg-str stmtend
*/
pathStatement : PATH_KEYWORD string STMTEND;
pathStatement : PATH_KEYWORD path STMTEND;
/**
* require-instance-stmt = require-instance-keyword sep
......@@ -657,7 +653,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
* position-value-arg >
* position-value-arg = non-negative-integer-value
*/
positionStatement : POSITION_KEYWORD string STMTEND;
positionStatement : POSITION_KEYWORD position STMTEND;
/**
* status-stmt = status-keyword sep status-arg-str stmtend
......@@ -667,7 +663,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
* obsolete-keyword /
* deprecated-keyword
*/
statusStatement : STATUS_KEYWORD (CURRENT_KEYWORD | OBSOLETE_KEYWORD | DEPRECATED_KEYWORD) STMTEND;
statusStatement : STATUS_KEYWORD status STMTEND;
/**
* config-stmt = config-keyword sep
......@@ -676,7 +672,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
* config-arg >
* config-arg = true-keyword / false-keyword
*/
configStatement : CONFIG_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;
configStatement : CONFIG_KEYWORD config STMTEND;
/**
* mandatory-stmt = mandatory-keyword sep
......@@ -687,7 +683,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
*
* mandatory-arg = true-keyword / false-keyword
*/
mandatoryStatement : MANDATORY_KEYWORD (TRUE_KEYWORD | FALSE_KEYWORD) STMTEND;
mandatoryStatement : MANDATORY_KEYWORD mandatory STMTEND;
/**
* presence-stmt = presence-keyword sep string stmtend
......@@ -703,7 +699,7 @@ package org.onosproject.yangutils.parser.antlrgencode;
*
* ordered-by-arg = user-keyword / system-keyword
*/
orderedByStatement : ORDERED_BY_KEYWORD (USER_KEYWORD | SYSTEM_KEYWORD) STMTEND;
orderedByStatement : ORDERED_BY_KEYWORD orderedBy STMTEND;
/**
* must-stmt = must-keyword sep string optsep
......@@ -735,22 +731,17 @@ package org.onosproject.yangutils.parser.antlrgencode;
* min-value-arg >
* min-value-arg = non-negative-integer-value
*/
minElementsStatement : MIN_ELEMENTS_KEYWORD INTEGER STMTEND;
minElementsStatement : MIN_ELEMENTS_KEYWORD minValue STMTEND;
/**
* max-elements-stmt = max-elements-keyword sep
* max-value-arg-str stmtend
* max-value-arg-str = < a string that matches the rule
* max-value-arg >
*/
maxElementsStatement : MAX_ELEMENTS_KEYWORD maxValueArgument STMTEND;
/**
* max-value-arg = unbounded-keyword /
* positive-integer-value
*/
maxValueArgument : UNBOUNDED_KEYWORD | INTEGER;
maxElementsStatement : MAX_ELEMENTS_KEYWORD maxValue STMTEND;
/**
* value-stmt = value-keyword sep integer-value stmtend
......@@ -873,12 +864,12 @@ package org.onosproject.yangutils.parser.antlrgencode;
/**
* key-stmt = key-keyword sep key-arg-str stmtend
*/
keyStatement : KEY_KEYWORD string STMTEND;
keyStatement : KEY_KEYWORD key STMTEND;
/**
* unique-stmt = unique-keyword sep unique-arg-str stmtend
*/
uniqueStatement: UNIQUE_KEYWORD string STMTEND;
uniqueStatement: UNIQUE_KEYWORD unique STMTEND;
/**
* choice-stmt = choice-keyword sep identifier-arg-str optsep
......@@ -958,9 +949,9 @@ package org.onosproject.yangutils.parser.antlrgencode;
* refine-anyxml-stmts)
* "}")
*/
refineStatement : REFINE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE (refineContainerStatements | refineLeafStatements
| refineLeafListStatements | refineListStatements | refineChoiceStatements | refineCaseStatements)
RIGHT_CURLY_BRACE);
refineStatement : REFINE_KEYWORD refine (STMTEND | LEFT_CURLY_BRACE (refineContainerStatements
| refineLeafStatements | refineLeafListStatements | refineListStatements | refineChoiceStatements
| refineCaseStatements) RIGHT_CURLY_BRACE);
/**
* refine-container-stmts =
......@@ -1046,8 +1037,9 @@ package org.onosproject.yangutils.parser.antlrgencode;
* "}"
* TODO : 0..1 occurance to be checked in listener
*/
usesAugmentStatement : AUGMENT_KEYWORD string LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement | statusStatement
| descriptionStatement | referenceStatement | dataDefStatement | caseStatement)* RIGHT_CURLY_BRACE;
usesAugmentStatement : AUGMENT_KEYWORD augment LEFT_CURLY_BRACE (whenStatement | ifFeatureStatement
| statusStatement | descriptionStatement | referenceStatement | dataDefStatement
| caseStatement)* RIGHT_CURLY_BRACE;
/**
* augment-stmt = augment-keyword sep augment-arg-str optsep
......@@ -1158,9 +1150,9 @@ package org.onosproject.yangutils.parser.antlrgencode;
* "}"
* TODO : 0..1 occurance to be checked in listener
*/
deviationStatement: DEVIATION_KEYWORD string LEFT_CURLY_BRACE (descriptionStatement | referenceStatement
| deviateNotSupportedStatement | deviateAddStatement | deviateReplaceStatement | deviateDeleteStatement)*
RIGHT_CURLY_BRACE;
deviationStatement: DEVIATION_KEYWORD deviation LEFT_CURLY_BRACE (descriptionStatement | referenceStatement
| deviateNotSupportedStatement | deviateAddStatement | deviateReplaceStatement
| deviateDeleteStatement)* RIGHT_CURLY_BRACE;
/**
* deviate-not-supported-stmt =
......@@ -1222,10 +1214,61 @@ package org.onosproject.yangutils.parser.antlrgencode;
string : STRING (PLUS STRING)*
| IDENTIFIER
| INTEGER;
| INTEGER
| yangConstruct;
identifier : STRING (PLUS STRING)*
| IDENTIFIER;
| IDENTIFIER
| yangConstruct;
dateArgumentString : DATE_ARG
| STRING (PLUS STRING)*;
version : string;
range : string;
length : string;
path : string;
position : string;
status : string;
config : string;
mandatory : string;
orderedBy : string;
minValue : string;
maxValue : string;
key : string;
unique : string;
refine : string;
augment : string;
deviation : string;
yangConstruct : ANYXML_KEYWORD | ARGUMENT_KEYWORD | AUGMENT_KEYWORD | BASE_KEYWORD | BELONGS_TO_KEYWORD
| BIT_KEYWORD | CASE_KEYWORD | CHOICE_KEYWORD | CONFIG_KEYWORD | CONTACT_KEYWORD | CONTAINER_KEYWORD
| DEFAULT_KEYWORD | DESCRIPTION_KEYWORD | ENUM_KEYWORD ERROR_APP_TAG_KEYWORD | ERROR_MESSAGE_KEYWORD
| EXTENSION_KEYWORD | DEVIATION_KEYWORD | DEVIATE_KEYWORD | FEATURE_KEYWORD
| FRACTION_DIGITS_KEYWORD | GROUPING_KEYWORD | IDENTITY_KEYWORD | IF_FEATURE_KEYWORD
| IMPORT_KEYWORD | INCLUDE_KEYWORD | INPUT_KEYWORD | KEY_KEYWORD | LEAF_KEYWORD | LEAF_LIST_KEYWORD
| LENGTH_KEYWORD | LIST_KEYWORD | MANDATORY_KEYWORD | MAX_ELEMENTS_KEYWORD | MIN_ELEMENTS_KEYWORD
| MODULE_KEYWORD | MUST_KEYWORD | NAMESPACE_KEYWORD | NOTIFICATION_KEYWORD | ORDERED_BY_KEYWORD
| ORGANIZATION_KEYWORD | OUTPUT_KEYWORD | PATH_KEYWORD | PATTERN_KEYWORD |POSITION_KEYWORD
| PREFIX_KEYWORD | PRESENCE_KEYWORD | RANGE_KEYWORD | REFERENCE_KEYWORD | REFINE_KEYWORD
| REQUIRE_INSTANCE_KEYWORD | REVISION_KEYWORD | REVISION_DATE_KEYWORD | RPC_KEYWORD
| STATUS_KEYWORD | SUBMODULE_KEYWORD | TYPE_KEYWORD | TYPEDEF_KEYWORD | UNIQUE_KEYWORD
| UNITS_KEYWORD | USES_KEYWORD | VALUE_KEYWORD | WHEN_KEYWORD | YANG_VERSION_KEYWORD
| YIN_ELEMENT_KEYWORD | ADD_KEYWORD | CURRENT_KEYWORD | DELETE_KEYWORD | DEPRECATED_KEYWORD
| FALSE_KEYWORD | MAX_KEYWORD | MIN_KEYWORD | NOT_SUPPORTED_KEYWORD | OBSOLETE_KEYWORD
| REPLACE_KEYWORD | SYSTEM_KEYWORD | TRUE_KEYWORD | UNBOUNDED_KEYWORD | USER_KEYWORD;
\ No newline at end of file
......
......@@ -115,7 +115,7 @@ public class ConfigListenerTest {
@Test
public void processConfigInvalidValue() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("mismatched input 'invalid' expecting {'false', 'true'}");
thrown.expectMessage("YANG file error : config value invalid is not valid.");
YangNode node = manager.getDataModel("src/test/resources/ConfigInvalidValue.yang");
}
......@@ -125,7 +125,7 @@ public class ConfigListenerTest {
@Test
public void processConfigEmptyValue() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("missing {'false', 'true'} at ';'");
thrown.expectMessage("no viable alternative at input ';'");
YangNode node = manager.getDataModel("src/test/resources/ConfigEmptyValue.yang");
}
......
......@@ -126,7 +126,7 @@ public class MandatoryListenerTest {
@Test
public void processMandatoryEmptyStatement() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("missing {'false', 'true'} at ';'");
thrown.expectMessage("no viable alternative at input ';'");
YangNode node = manager.getDataModel("src/test/resources/MandatoryEmptyStatement.yang");
}
......
......@@ -111,7 +111,7 @@ public class MinElementsListenerTest {
@Test
public void processMinElementsInvalidValue() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("mismatched input 'asd' expecting INTEGER");
thrown.expectMessage("YANG file error : min-elements value asd is not valid.");
YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidValue.yang");
}
......
......@@ -141,7 +141,7 @@ public class StatusListenerTest {
@Test
public void processStatusInvalidValue() throws IOException, ParserException {
thrown.expect(ParserException.class);
thrown.expectMessage("mismatched input 'invalid' expecting {'current', 'deprecated', 'obsolete'}");
thrown.expectMessage("Invalid content in status \"invalid\" before processing.");
YangNode node = manager.getDataModel("src/test/resources/StatusInvalidValue.yang");
}
......