Merge "BUG-1413: fixed bug in antlr grammar."
authorTony Tkacik <ttkacik@cisco.com>
Tue, 29 Jul 2014 09:14:02 +0000 (09:14 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 29 Jul 2014 09:14:02 +0000 (09:14 +0000)
yang/yang-parser-impl/src/main/antlr/YangParser.g4
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug1413Test.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug1413/bug1413.yang [new file with mode: 0644]

index dcf0e94404112045735c7755a1bee9e464283487..0de03b83cb1cf482b0ceca228ffd72726fc35c25 100644 (file)
@@ -136,7 +136,7 @@ base_stmt : BASE_KEYWORD string stmtend;
 identity_stmt : IDENTITY_KEYWORD string (SEMICOLON | (LEFT_BRACE  (identifier_stmt | base_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
 yin_element_arg : string; // TRUE_KEYWORD | FALSE_KEYWORD;
 yin_element_stmt : YIN_ELEMENT_KEYWORD yin_element_arg stmtend;
-argument_stmt : ARGUMENT_KEYWORD string (SEMICOLON | (LEFT_BRACE  (unknown_statement2)? (yin_element_stmt)? RIGHT_BRACE));
+argument_stmt : ARGUMENT_KEYWORD string (SEMICOLON | (LEFT_BRACE  (unknown_statement2)* (yin_element_stmt)? (unknown_statement2)* RIGHT_BRACE));
 extension_stmt : EXTENSION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (unknown_statement | argument_stmt | status_stmt | description_stmt | reference_stmt )* RIGHT_BRACE));
 revision_date_stmt : REVISION_DATE_KEYWORD string stmtend;
 revision_stmt : REVISION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (description_stmt )? (reference_stmt )? RIGHT_BRACE));
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug1413Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug1413Test.java
new file mode 100644 (file)
index 0000000..4241414
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Set;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.Module;
+
+/**
+ * Test antlr grammar capability to parse unknown node in extension argument
+ * declaration.
+ *
+ * Not that everything under unknown node is unknown node.
+ */
+public class Bug1413Test {
+
+    @Test
+    public void test() throws Exception {
+        Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug1413").toURI());
+        Module bug1413 = TestUtils.findModule(modules, "bug1413");
+        assertNotNull(bug1413);
+
+        List<ExtensionDefinition> extensions = bug1413.getExtensionSchemaNodes();
+        assertEquals(1, extensions.size());
+
+        ExtensionDefinition info = extensions.get(0);
+        assertEquals("text", info.getArgument());
+        assertTrue(info.isYinElement());
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug1413/bug1413.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug1413/bug1413.yang
new file mode 100644 (file)
index 0000000..b691ef8
--- /dev/null
@@ -0,0 +1,19 @@
+module bug1413 {
+    yang-version 1;
+    namespace "odl:test:bug1413";
+    prefix "b1413";
+
+    revision "2014-07-25" {
+    }
+
+
+    extension info {
+        argument text {
+            yin-element true;
+            ext:arg-type {
+                type string;
+            }
+        }
+    }
+
+}