Fix Bug 2291 32/12432/1
authorLoi Pan <mr.loipan@gmail.com>
Fri, 31 Oct 2014 22:59:49 +0000 (23:59 +0100)
committerLoi Pan <mr.loipan@gmail.com>
Fri, 31 Oct 2014 23:49:52 +0000 (00:49 +0100)
Change-Id: Ie86cd6f61648aefc81c80c53866e2421216cd111
Signed-off-by: Loi Pan <mr.loipan@gmail.com>
yang/yang-parser-impl/src/main/antlr/YangParser.g4
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang [new file with mode: 0644]

index 3484b79fc342ad072c911e170fd1aed653c7a15e..59005a2896cc7794234f8c4df5c3ed6b7cdc56a4 100644 (file)
@@ -125,7 +125,7 @@ yin_element_stmt : YIN_ELEMENT_KEYWORD yin_element_arg stmtend;
 argument_stmt : ARGUMENT_KEYWORD string (SEMICOLON | (LEFT_BRACE identifier_stmt* yin_element_stmt? identifier_stmt* RIGHT_BRACE));
 extension_stmt : EXTENSION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (argument_stmt | status_stmt | description_stmt | reference_stmt | unknown_statement)* RIGHT_BRACE));
 revision_date_stmt : REVISION_DATE_KEYWORD string stmtend;
-revision_stmt : REVISION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (description_stmt )? (reference_stmt )? RIGHT_BRACE));
+revision_stmt : REVISION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (description_stmt )? (reference_stmt )? (unknown_statement)? RIGHT_BRACE));
 units_stmt : UNITS_KEYWORD string stmtend;
 reference_stmt : REFERENCE_KEYWORD string stmtend;
 description_stmt : DESCRIPTION_KEYWORD string stmtend;
@@ -145,4 +145,4 @@ meta_stmts : (organization_stmt stmtsep* | contact_stmt stmtsep* | description_s
 submodule_header_stmts : (yang_version_stmt stmtsep* | belongs_to_stmt stmtsep*)+ ;
 module_header_stmts :  (yang_version_stmt stmtsep* | namespace_stmt stmtsep* | prefix_stmt stmtsep*)+ ;
 submodule_stmt : SUBMODULE_KEYWORD string LEFT_BRACE  submodule_header_stmts linkage_stmts meta_stmts revision_stmts body_stmts RIGHT_BRACE;
-module_stmt : MODULE_KEYWORD string LEFT_BRACE stmtsep* module_header_stmts linkage_stmts meta_stmts revision_stmts body_stmts RIGHT_BRACE;
\ No newline at end of file
+module_stmt : MODULE_KEYWORD string LEFT_BRACE stmtsep* module_header_stmts linkage_stmts meta_stmts revision_stmts body_stmts RIGHT_BRACE;
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java
new file mode 100644 (file)
index 0000000..50c94f9
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
+import org.opendaylight.yangtools.yang.model.util.BitsType;
+import org.opendaylight.yangtools.yang.model.util.EnumerationType;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
+import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
+
+public class Bug2291Test {
+
+    @Test
+    public void testRevisionWithExt() throws Exception {
+        File extdef = new File(getClass().getResource("/bugs/bug2291/bug2291-ext.yang").toURI());
+        File bug = new File(getClass().getResource("/bugs/bug2291/bug2291.yang").toURI());
+        File inet = new File(getClass().getResource("/ietf/ietf-inet-types@2010-09-24.yang").toURI());
+        YangContextParser parser = new YangParserImpl();
+        parser.parseFiles(Arrays.asList(extdef, bug, inet));
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang
new file mode 100644 (file)
index 0000000..f059a8d
--- /dev/null
@@ -0,0 +1,13 @@
+module "bug2291-ext" {
+    yang-version 1;
+    namespace "urn:test:bug:bug2291-ext";
+    prefix "bug2291-ext";
+
+    revision 2012-04-16 {
+    }
+
+    extension migration {
+        argument level;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang
new file mode 100644 (file)
index 0000000..90962b4
--- /dev/null
@@ -0,0 +1,22 @@
+module bug2291 {
+    yang-version 1;
+    namespace "urn:test:bug:bug2291";
+    prefix "bug2291";
+
+    import bug2291-ext {
+        prefix bug2291-ext;
+    }
+
+    import ietf-inet-types {
+        prefix "inet";
+    }
+
+    revision 2012-04-16 {
+        description "Initial revision";
+        bug2291-ext:migration 1;
+    }
+
+    leaf test {
+        type string;
+    }
+}