[ONOS-7304] YANG Runtime: YANG Push test for anydata
Change-Id: Ie2757343ef2598629c1e81b2f9ec5a265851e778
diff --git a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/antlrgencode/GeneratedYangListener.java b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/antlrgencode/GeneratedYangListener.java
index 432a122..ff61df3 100644
--- a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/antlrgencode/GeneratedYangListener.java
+++ b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/antlrgencode/GeneratedYangListener.java
@@ -1772,4 +1772,18 @@
* @param currentContext current context in the parsed tree
*/
void exitAnydataStatement(AnydataStatementContext currentContext);
+ /**
+ * Enters a parse tree produced by GeneratedYangParser for grammar rule
+ * YangStatement.
+ *
+ * @param currentContext current context in the parsed tree
+ */
+ void enterYangStatement(YangStatementContext currentContext);
+ /**
+ * Exits a parse tree produced by GeneratedYangParser for grammar rule
+ * YangStatement.
+ *
+ * @param currentContext current context in the parsed tree
+ */
+ void exitYangStatement(YangStatementContext currentContext);
}
diff --git a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListener.java b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListener.java
index 749843f..ba038cd 100644
--- a/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListener.java
+++ b/compiler/base/parser/src/main/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListener.java
@@ -24,6 +24,7 @@
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
import org.onosproject.yang.compiler.parser.antlrgencode.GeneratedYangListener;
import org.onosproject.yang.compiler.parser.antlrgencode.GeneratedYangParser.AnydataStatementContext;
+import org.onosproject.yang.compiler.parser.antlrgencode.GeneratedYangParser.YangStatementContext;
import org.onosproject.yang.compiler.parser.impl.listeners.AnydataListener;
import org.onosproject.yang.compiler.parser.impl.listeners.AppDataStructureListener;
import org.onosproject.yang.compiler.parser.impl.listeners.AppExtendedNameListener;
@@ -1956,6 +1957,16 @@
}
@Override
+ public void enterYangStatement(YangStatementContext currentContext) {
+ // do nothing
+ }
+
+ @Override
+ public void exitYangStatement(YangStatementContext currentContext) {
+ // do nothing
+ }
+
+ @Override
public void enterAnydataStatement(AnydataStatementContext ctx) {
AnydataListener.processAnydataEntry(this, ctx);
}
diff --git a/compiler/base/parser/src/main/resources/GeneratedYang.g4 b/compiler/base/parser/src/main/resources/GeneratedYang.g4
index e30e150..2203389 100644
--- a/compiler/base/parser/src/main/resources/GeneratedYang.g4
+++ b/compiler/base/parser/src/main/resources/GeneratedYang.g4
@@ -1225,8 +1225,8 @@
* *(data-def-stmt stmtsep)
* "}")
*/
- notificationStatement : NOTIFICATION_KEYWORD identifier (STMTEND | stmtSep
- LEFT_CURLY_BRACE ((ifFeatureStatement | statusStatement
+ notificationStatement : NOTIFICATION_KEYWORD identifier (STMTEND |
+ LEFT_CURLY_BRACE stmtSep ((ifFeatureStatement | statusStatement
| descriptionStatement | referenceStatement | typedefStatement
| defaultDenyAllStatement | groupingStatement | dataDefStatement)
stmtSep)* RIGHT_CURLY_BRACE);
@@ -1386,7 +1386,8 @@
* (";" / "{" *unknown-statement2 "}")
*/
unknownStatement : unknown string? (STMTEND
- | LEFT_CURLY_BRACE unknownStatement2* RIGHT_CURLY_BRACE);
+ | LEFT_CURLY_BRACE (yangStatement |unknownStatement2)*
+ RIGHT_CURLY_BRACE) stmtSep;
/**
* unknown-statement2 = [prefix ":"] identifier [sep string] optsep
@@ -1396,6 +1397,106 @@
| LEFT_CURLY_BRACE unknownStatement2* RIGHT_CURLY_BRACE);
/**
+ * yang-stmt as per RFC 7950
+ * yang-stmt = action-stmt / -- not handled
+ * anydata-stmt /
+ * anyxml-stmt /
+ * argument-stmt /
+ * augment-stmt /
+ * base-stmt /
+ * belongs-to-stmt /
+ * bit-stmt /
+ * case-stmt /
+ * choice-stmt /
+ * config-stmt /
+ * contact-stmt /
+ * container-stmt /
+ * default-stmt /
+ * description-stmt /
+ * deviate-add-stmt /
+ * deviate-delete-stmt /
+ * deviate-not-supported-stmt /
+ * deviate-replace-stmt /
+ * deviation-stmt /
+ * enum-stmt /
+ * error-app-tag-stmt /
+ * error-message-stmt /
+ * extension-stmt /
+ * feature-stmt /
+ * fraction-digits-stmt /
+ * grouping-stmt /
+ * identity-stmt /
+ * if-feature-stmt /
+ * import-stmt /
+ * include-stmt /
+ * input-stmt /
+ * key-stmt /
+ * leaf-list-stmt /
+ * leaf-stmt /
+ * length-stmt /
+ * list-stmt /
+ * mandatory-stmt /
+ * max-elements-stmt /
+ * min-elements-stmt /
+ * modifier-stmt / -- not handled
+ * module-stmt /
+ * must-stmt /
+ * namespace-stmt /
+ * notification-stmt /
+ * ordered-by-stmt /
+ * organization-stmt /
+ * output-stmt /
+ * path-stmt /
+ * pattern-stmt /
+ * position-stmt /
+ * prefix-stmt /
+ * presence-stmt /
+ * range-stmt /
+ * reference-stmt /
+ * refine-stmt /
+ * require-instance-stmt /
+ * revision-date-stmt /
+ * revision-stmt /
+ * rpc-stmt /
+ * status-stmt /
+ * submodule-stmt /
+ * typedef-stmt /
+ * type-stmt /
+ * unique-stmt /
+ * units-stmt /
+ * uses-augment-stmt / -- not handled
+ * uses-stmt /
+ * value-stmt /
+ * when-stmt /
+ * yang-version-stmt /
+ * yin-element-stmt
+ * ;; Ranges
+ */
+ yangStatement : anydataStatement
+ | anyxmlStatement | argumentStatement | augmentStatement
+ | baseStatement | belongstoStatement | bitStatement
+ | caseStatement | choiceStatement | configStatement
+ | contactStatement | containerStatement | defaultStatement
+ | descriptionStatement | deviationStatement | enumStatement
+ | errorAppTagStatement | errorMessageStatement | extensionStatement
+ | featureStatement | fractionDigitStatement | groupingStatement
+ | identityStatement | ifFeatureStatement | importStatement
+ | includeStatement | inputStatement | keyStatement
+ | leafListStatement | leafStatement | lengthStatement
+ | listStatement | mandatoryStatement | maxElementsStatement
+ | minElementsStatement | moduleStatement | mustStatement
+ | namespaceStatement | notificationStatement | orderedByStatement
+ | organizationStatement | outputStatement | pathStatement
+ | patternStatement | positionStatement | prefixStatement
+ | presenceStatement | rangeStatement | referenceStatement
+ | refineStatement | requireInstanceStatement | revisionDateStatement
+ | revisionStatement | rpcStatement | statusStatement
+ | subModuleStatement | typedefStatement | typeStatement
+ | uniqueStatement | unitsStatement | usesStatement
+ | valueStatement | whenStatement | yangVersionStatement
+ | yinElementStatement ;
+
+ /**
* stmtend = ";" / "{" *unknown-statement "}"
*/
stmtEnd : STMTEND | LEFT_CURLY_BRACE unknownStatement* RIGHT_CURLY_BRACE;
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaAnydataTranslator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaAnydataTranslator.java
index 598ac92..89c3a45 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaAnydataTranslator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaAnydataTranslator.java
@@ -27,6 +27,7 @@
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yang.compiler.translator.tojava.YangJavaModelUtils.generateCodeAndUpdateInParent;
+import static org.onosproject.yang.compiler.translator.tojava.YangJavaModelUtils.generateJava;
/**
* Represents container information extended to support java code generation.
@@ -128,8 +129,7 @@
@Override
public void generateCodeExit() throws TranslatorException {
try {
- getTempJavaCodeFragmentFiles().generateJavaFile(
- GENERATE_INTERFACE_WITH_BUILDER, this);
+ generateJava(GENERATE_INTERFACE_WITH_BUILDER, this);
} catch (IOException e) {
throw new TranslatorException("Failed to generate code for " +
"anydata node " +