YANG rpc, input and output listener

Change-Id: Idd9847175c61d9f033cf80213b46e9c9c949849c
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java b/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java
index 92b3420..4e488bb 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java
@@ -26,6 +26,9 @@
 import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.datamodel.YangUses;
 import org.onosproject.yangutils.datamodel.YangNotification;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangInput;
+import org.onosproject.yangutils.datamodel.YangOutput;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice;
@@ -37,6 +40,9 @@
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput;
 
 /**
  * Factory to create data model objects based on the target file type.
@@ -246,4 +252,58 @@
             }
         }
     }
+
+    /**
+     * Based on the target language generate the inherited data model node.
+     *
+     * @param targetLanguage target language in which YANG mapping needs to be
+     *            generated
+     * @return the corresponding inherited node based on the target language
+     */
+    public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) {
+        switch (targetLanguage) {
+            case JAVA_GENERATION: {
+                return new YangJavaRpc();
+            }
+            default: {
+                throw new RuntimeException("Only YANG to Java is supported.");
+            }
+        }
+    }
+
+    /**
+     * Based on the target language generate the inherited data model node.
+     *
+     * @param targetLanguage target language in which YANG mapping needs to be
+     *            generated
+     * @return the corresponding inherited node based on the target language
+     */
+    public static YangInput getYangInputNode(GeneratedLanguage targetLanguage) {
+        switch (targetLanguage) {
+            case JAVA_GENERATION: {
+                return new YangJavaInput();
+            }
+            default: {
+                throw new RuntimeException("Only YANG to Java is supported.");
+            }
+        }
+    }
+
+    /**
+     * Based on the target language generate the inherited data model node.
+     *
+     * @param targetLanguage target language in which YANG mapping needs to be
+     *            generated
+     * @return the corresponding inherited node based on the target language
+     */
+    public static YangOutput getYangOutputNode(GeneratedLanguage targetLanguage) {
+        switch (targetLanguage) {
+            case JAVA_GENERATION: {
+                return new YangJavaOutput();
+            }
+            default: {
+                throw new RuntimeException("Only YANG to Java is supported.");
+            }
+        }
+    }
 }
diff --git a/src/main/java/org/onosproject/yangutils/parser/antlrgencode/GeneratedYangListener.java b/src/main/java/org/onosproject/yangutils/parser/antlrgencode/GeneratedYangListener.java
index b566464..cec4df4 100644
--- a/src/main/java/org/onosproject/yangutils/parser/antlrgencode/GeneratedYangListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/antlrgencode/GeneratedYangListener.java
@@ -1562,6 +1562,22 @@
 
     /**
      * Enter a parse tree produced by GeneratedYangParser for grammar rule
+     * inputStatementBody.
+     *
+     * @param currentContext current context in the parsed tree
+     */
+    void enterInputStatementBody(GeneratedYangParser.InputStatementBodyContext currentContext);
+
+    /**
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule
+     * inputStatementBody.
+     *
+     * @param currentContext current context in the parsed tree
+     */
+    void exitInputStatementBody(GeneratedYangParser.InputStatementBodyContext currentContext);
+
+    /**
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule
      * outputStatement.
      *
      * @param currentContext current context in the parsed tree
@@ -1578,6 +1594,22 @@
 
     /**
      * Enter a parse tree produced by GeneratedYangParser for grammar rule
+     * outputStatementBody.
+     *
+     * @param currentContext current context in the parsed tree
+     */
+    void enterOutputStatementBody(GeneratedYangParser.OutputStatementBodyContext currentContext);
+
+    /**
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule
+     * outputStatementBody.
+     *
+     * @param currentContext current context in the parsed tree
+     */
+    void exitOutputStatementBody(GeneratedYangParser.OutputStatementBodyContext currentContext);
+
+    /**
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule
      * notificationStatement.
      *
      * @param currentContext current context in the parsed tree
@@ -1625,368 +1657,322 @@
     void exitDeviateNotSupportedStatement(GeneratedYangParser.DeviateNotSupportedStatementContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * deviateAddStatement.
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule deviateAddStatement.
      *
      * @param currentContext current context in the parsed tree
      */
     void enterDeviateAddStatement(GeneratedYangParser.DeviateAddStatementContext currentContext);
 
     /**
-     * Exit a parse tree produced by GeneratedYangParser for grammar rule
-     * deviateAddStatement.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule deviateAddStatement.
      *
      * @param currentContext current context in the parsed tree
      */
     void exitDeviateAddStatement(GeneratedYangParser.DeviateAddStatementContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * deviateDeleteStatement.
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule deviateDeleteStatement.
      *
      * @param currentContext current context in the parsed tree
      */
     void enterDeviateDeleteStatement(GeneratedYangParser.DeviateDeleteStatementContext currentContext);
 
     /**
-     * Exit a parse tree produced by GeneratedYangParser for grammar rule
-     * deviateDeleteStatement.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule deviateDeleteStatement.
      *
      * @param currentContext current context in the parsed tree
      */
     void exitDeviateDeleteStatement(GeneratedYangParser.DeviateDeleteStatementContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * deviateReplaceStatement.
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule deviateReplaceStatement.
      *
      * @param currentContext current context in the parsed tree
      */
     void enterDeviateReplaceStatement(GeneratedYangParser.DeviateReplaceStatementContext currentContext);
 
     /**
-     * Exit a parse tree produced by GeneratedYangParser for grammar rule
-     * deviateReplaceStatement.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule deviateReplaceStatement.
      *
      * @param currentContext current context in the parsed tree
      */
     void exitDeviateReplaceStatement(GeneratedYangParser.DeviateReplaceStatementContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * string.
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule string.
      *
      * @param currentContext current context in the parsed tree
      */
     void enterString(GeneratedYangParser.StringContext currentContext);
 
     /**
-     * Exit a parse tree produced by GeneratedYangParser for grammar rule
-     * string.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule string.
      *
      * @param currentContext current context in the parsed tree
      */
     void exitString(GeneratedYangParser.StringContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * identifier.
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule identifier.
      *
      * @param currentContext current context in the parsed tree
      */
     void enterIdentifier(GeneratedYangParser.IdentifierContext currentContext);
 
     /**
-     * Exit a parse tree produced by GeneratedYangParser for grammar rule
-     * identifier.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule identifier.
      *
      * @param currentContext current context in the parsed tree
      */
     void exitIdentifier(GeneratedYangParser.IdentifierContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * version.
+     * 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.
+     * 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.
+     * 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.
+     * 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
-     * dateArgumentString.
+     * Enter a parse tree produced by GeneratedYangParser for grammar rule dateArgumentString.
      *
      * @param currentContext current context in the parsed tree
      */
     void enterDateArgumentString(GeneratedYangParser.DateArgumentStringContext currentContext);
 
     /**
-     * Exit a parse tree produced by GeneratedYangParser for grammar rule
-     * dateArgumentString.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule dateArgumentString.
      *
      * @param currentContext current context in the parsed tree
      */
     void exitDateArgumentString(GeneratedYangParser.DateArgumentStringContext currentContext);
 
     /**
-     * Enter a parse tree produced by GeneratedYangParser for grammar rule
-     * length.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * 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.
+     * Exit a parse tree produced by GeneratedYangParser for grammar rule yang construct.
      *
      * @param currentContext current context in the parsed tree
      */
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
index 473ee0e..75f5396 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
@@ -42,6 +42,7 @@
 import org.onosproject.yangutils.parser.impl.listeners.GroupingListener;
 import org.onosproject.yangutils.parser.impl.listeners.ImportListener;
 import org.onosproject.yangutils.parser.impl.listeners.IncludeListener;
+import org.onosproject.yangutils.parser.impl.listeners.InputListener;
 import org.onosproject.yangutils.parser.impl.listeners.KeyListener;
 import org.onosproject.yangutils.parser.impl.listeners.LeafListListener;
 import org.onosproject.yangutils.parser.impl.listeners.LeafListener;
@@ -53,12 +54,14 @@
 import org.onosproject.yangutils.parser.impl.listeners.NotificationListener;
 import org.onosproject.yangutils.parser.impl.listeners.NamespaceListener;
 import org.onosproject.yangutils.parser.impl.listeners.OrganizationListener;
+import org.onosproject.yangutils.parser.impl.listeners.OutputListener;
 import org.onosproject.yangutils.parser.impl.listeners.PositionListener;
 import org.onosproject.yangutils.parser.impl.listeners.PrefixListener;
 import org.onosproject.yangutils.parser.impl.listeners.PresenceListener;
 import org.onosproject.yangutils.parser.impl.listeners.ReferenceListener;
 import org.onosproject.yangutils.parser.impl.listeners.RevisionDateListener;
 import org.onosproject.yangutils.parser.impl.listeners.RevisionListener;
+import org.onosproject.yangutils.parser.impl.listeners.RpcListener;
 import org.onosproject.yangutils.parser.impl.listeners.ShortCaseListener;
 import org.onosproject.yangutils.parser.impl.listeners.StatusListener;
 import org.onosproject.yangutils.parser.impl.listeners.SubModuleListener;
@@ -1062,32 +1065,48 @@
 
     @Override
     public void enterRpcStatement(GeneratedYangParser.RpcStatementContext ctx) {
-        // TODO: implement the method.
+        RpcListener.processRpcEntry(this, ctx);
     }
 
     @Override
     public void exitRpcStatement(GeneratedYangParser.RpcStatementContext ctx) {
-        // TODO: implement the method.
+        RpcListener.processRpcExit(this, ctx);
     }
 
     @Override
     public void enterInputStatement(GeneratedYangParser.InputStatementContext ctx) {
-        // TODO: implement the method.
+        InputListener.processInputEntry(this, ctx);
     }
 
     @Override
     public void exitInputStatement(GeneratedYangParser.InputStatementContext ctx) {
-        // TODO: implement the method.
+        InputListener.processInputExit(this, ctx);
+    }
+
+    @Override
+    public void enterInputStatementBody(GeneratedYangParser.InputStatementBodyContext ctx) {
+    }
+
+    @Override
+    public void exitInputStatementBody(GeneratedYangParser.InputStatementBodyContext ctx) {
     }
 
     @Override
     public void enterOutputStatement(GeneratedYangParser.OutputStatementContext ctx) {
-        // TODO: implement the method.
+        OutputListener.processOutputEntry(this, ctx);
     }
 
     @Override
     public void exitOutputStatement(GeneratedYangParser.OutputStatementContext ctx) {
-        // TODO: implement the method.
+        OutputListener.processOutputExit(this, ctx);
+    }
+
+    @Override
+    public void enterOutputStatementBody(GeneratedYangParser.OutputStatementBodyContext ctx) {
+    }
+
+    @Override
+    public void exitOutputStatementBody(GeneratedYangParser.OutputStatementBodyContext ctx) {
     }
 
     @Override
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java
new file mode 100644
index 0000000..255458d
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.onosproject.yangutils.datamodel.YangInput;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+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 static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
+import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangInputNode;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *
+ * input-stmt          = input-keyword optsep
+ *                       "{" stmtsep
+ *                           ;; these stmts can appear in any order
+ *                           *((typedef-stmt /
+ *                              grouping-stmt) stmtsep)
+ *                           1*(data-def-stmt stmtsep)
+ *                         "}"
+ *
+ * inputStatement : INPUT_KEYWORD LEFT_CURLY_BRACE inputStatementBody RIGHT_CURLY_BRACE;
+
+ * inputStatementBody : typedefStatement* dataDefStatement+
+ *                    | dataDefStatement+ typedefStatement*
+ *                    | groupingStatement* dataDefStatement+
+ *                    | dataDefStatement+ groupingStatement*;
+ */
+
+/**
+ * Implements listener based call back function corresponding to the "input"
+ * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ */
+public final class InputListener {
+
+    private static final String INPUT_KEYWORD = "Input";
+
+    /**
+     * Creates a new input listener.
+     */
+    private InputListener() {
+    }
+
+    /**
+     * It is called when parser receives an input matching the grammar rule
+     * (input), performs validation and updates the data model tree.
+     *
+     * @param listener listener's object
+     * @param ctx context object of the grammar rule
+     */
+    public static void processInputEntry(TreeWalkListener listener,
+                                       GeneratedYangParser.InputStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", ENTRY);
+
+        Parsable curData = listener.getParsedDataStack().peek();
+        if (curData instanceof YangRpc) {
+
+            YangInput yangInput = getYangInputNode(JAVA_GENERATION);
+            yangInput.setName(((YangRpc) curData).getName() + INPUT_KEYWORD);
+            YangNode curNode = (YangNode) curData;
+            try {
+                curNode.addChild(yangInput);
+            } catch (DataModelException e) {
+                throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                        INPUT_DATA, "", ENTRY, e.getMessage()));
+            }
+            listener.getParsedDataStack().push(yangInput);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, INPUT_DATA,
+                    "", ENTRY));
+        }
+    }
+
+    /**
+     * It is called when parser exits from grammar rule (input), it perform
+     * validations and updates the data model tree.
+     *
+     * @param listener listener's object
+     * @param ctx context object of the grammar rule
+     */
+    public static void processInputExit(TreeWalkListener listener,
+                                      GeneratedYangParser.InputStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", EXIT);
+
+        if (!(listener.getParsedDataStack().peek() instanceof YangInput)) {
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, INPUT_DATA,
+                    "", EXIT));
+        }
+        listener.getParsedDataStack().pop();
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java
new file mode 100644
index 0000000..19f39e8
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+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 static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
+import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangOutputNode;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *
+ *  output-stmt         = output-keyword optsep
+ *                        "{" stmtsep
+ *                            ;; these stmts can appear in any order
+ *                            *((typedef-stmt /
+ *                               grouping-stmt) stmtsep)
+ *                            1*(data-def-stmt stmtsep)
+ *                        "}"
+ *
+ *  outputStatement : OUTPUT_KEYWORD LEFT_CURLY_BRACE outputStatementBody RIGHT_CURLY_BRACE;
+
+ *  outputStatementBody : typedefStatement* dataDefStatement+
+ *                      | dataDefStatement+ typedefStatement*
+ *                      | groupingStatement* dataDefStatement+
+ *                      | dataDefStatement+ groupingStatement*;
+ */
+
+/**
+ * Implements listener based call back function corresponding to the "output"
+ * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ */
+public final class OutputListener {
+
+    private static final String OUTPUT_KEYWORD = "Output";
+
+    /**
+     * Creates a new output listener.
+     */
+    private OutputListener() {
+    }
+
+    /**
+     * It is called when parser receives an input matching the grammar rule
+     * (output), performs validation and updates the data model tree.
+     *
+     * @param listener listener's object
+     * @param ctx context object of the grammar rule
+     */
+    public static void processOutputEntry(TreeWalkListener listener,
+                                         GeneratedYangParser.OutputStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", ENTRY);
+
+        Parsable curData = listener.getParsedDataStack().peek();
+        if (curData instanceof YangRpc) {
+
+            YangOutput yangOutput = getYangOutputNode(JAVA_GENERATION);
+            yangOutput.setName(((YangRpc) curData).getName() + OUTPUT_KEYWORD);
+            YangNode curNode = (YangNode) curData;
+            try {
+                curNode.addChild(yangOutput);
+            } catch (DataModelException e) {
+                throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                        OUTPUT_DATA, "", ENTRY, e.getMessage()));
+            }
+            listener.getParsedDataStack().push(yangOutput);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, OUTPUT_DATA,
+                    "", ENTRY));
+        }
+    }
+
+    /**
+     * It is called when parser exits from grammar rule (output), it perform
+     * validations and updates the data model tree.
+     *
+     * @param listener listener's object
+     * @param ctx context object of the grammar rule
+     */
+    public static void processOutputExit(TreeWalkListener listener,
+                                        GeneratedYangParser.OutputStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", EXIT);
+
+        if (!(listener.getParsedDataStack().peek() instanceof YangOutput)) {
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, OUTPUT_DATA,
+                    "", EXIT));
+        }
+        listener.getParsedDataStack().pop();
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RpcListener.java b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RpcListener.java
new file mode 100644
index 0000000..786851b
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RpcListener.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+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 static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
+import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangRpcNode;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds;
+import static org.onosproject.yangutils.utils.YangConstructType.RPC_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
+import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *  rpc-stmt            = rpc-keyword sep identifier-arg-str optsep
+ *                        (";" /
+ *                         "{" stmtsep
+ *                             ;; these stmts can appear in any order
+ *                             *(if-feature-stmt stmtsep)
+ *                             [status-stmt stmtsep]
+ *                             [description-stmt stmtsep]
+ *                             [reference-stmt stmtsep]
+ *                             *((typedef-stmt /
+ *                                grouping-stmt) stmtsep)
+ *                             [input-stmt stmtsep]
+ *                             [output-stmt stmtsep]
+ *                         "}")
+ *
+ * ANTLR grammar rule
+ *  rpcStatement : RPC_KEYWORD identifier (STMTEND | LEFT_CURLY_BRACE (ifFeatureStatement | statusStatement
+ *               | descriptionStatement | referenceStatement | typedefStatement | groupingStatement | inputStatement
+ *               | outputStatement)* RIGHT_CURLY_BRACE);
+ */
+
+/**
+ * Implements listener based call back function corresponding to the "rpc"
+ * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ */
+public final class RpcListener {
+
+    /**
+     * Creates a new rpc listener.
+     */
+    private RpcListener() {
+    }
+
+    /**
+     * It is called when parser receives an input matching the grammar rule
+     * (rpc), performs validation and updates the data model tree.
+     *
+     * @param listener listener's object
+     * @param ctx context object of the grammar rule
+     */
+    public static void processRpcEntry(TreeWalkListener listener,
+                                             GeneratedYangParser.RpcStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, RPC_DATA, ctx.identifier().getText(), ENTRY);
+
+        String identifier = getValidIdentifier(ctx.identifier().getText(), RPC_DATA, ctx);
+
+        // Validate sub statement cardinality.
+        validateSubStatementsCardinality(ctx);
+
+        // Check for identifier collision
+        int line = ctx.getStart().getLine();
+        int charPositionInLine = ctx.getStart().getCharPositionInLine();
+        detectCollidingChildUtil(listener, line, charPositionInLine, identifier, RPC_DATA);
+
+        Parsable curData = listener.getParsedDataStack().peek();
+        if (curData instanceof YangModule || curData instanceof YangSubModule) {
+
+            YangNode curNode = (YangNode) curData;
+            YangRpc yangRpc = getYangRpcNode(JAVA_GENERATION);
+            yangRpc.setName(identifier);
+            try {
+                curNode.addChild(yangRpc);
+            } catch (DataModelException e) {
+                throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                        RPC_DATA, ctx.identifier().getText(), ENTRY, e.getMessage()));
+            }
+            listener.getParsedDataStack().push(yangRpc);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, RPC_DATA,
+                    ctx.identifier().getText(), ENTRY));
+        }
+    }
+
+    /**
+     * It is called when parser exits from grammar rule (rpc), it perform
+     * validations and updates the data model tree.
+     *
+     * @param listener listener's object
+     * @param ctx context object of the grammar rule
+     */
+    public static void processRpcExit(TreeWalkListener listener,
+                                            GeneratedYangParser.RpcStatementContext ctx) {
+
+         //Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, RPC_DATA, ctx.identifier().getText(), EXIT);
+
+        if (!(listener.getParsedDataStack().peek() instanceof YangRpc)) {
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, RPC_DATA,
+                    ctx.identifier().getText(), EXIT));
+        }
+        listener.getParsedDataStack().pop();
+    }
+
+    /**
+     * Validates the cardinality of rpc sub-statements as per grammar.
+     *
+     * @param ctx context object of the grammar rule
+     */
+    private static void validateSubStatementsCardinality(GeneratedYangParser.RpcStatementContext ctx) {
+
+        validateCardinalityMaxOne(ctx.statusStatement(), STATUS_DATA, RPC_DATA, ctx.identifier().getText());
+        validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, RPC_DATA, ctx.identifier().getText());
+        validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, RPC_DATA, ctx.identifier().getText());
+        validateCardinalityMaxOne(ctx.inputStatement(), INPUT_DATA, RPC_DATA, ctx.identifier().getText());
+        validateCardinalityMaxOne(ctx.outputStatement(), OUTPUT_DATA, RPC_DATA, ctx.identifier().getText());
+        validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA,
+                RPC_DATA, ctx.identifier().getText());
+    }
+
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
new file mode 100644
index 0000000..6d7776b
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.javamodel;
+
+import java.io.IOException;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+
+/**
+ * Rpc information extended to support java code generation.
+ */
+public class YangJavaRpc extends YangRpc implements JavaCodeGenerator {
+
+    /**
+     * Creates an instance of java Rpc.
+     */
+    public YangJavaRpc() {
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * rpc info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+          // TODO
+    }
+
+    /**
+     * Create a java file using the YANG rpc info.
+     *
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeExit() throws IOException {
+          // TODO
+    }
+}
diff --git a/src/main/resources/GeneratedYang.g4 b/src/main/resources/GeneratedYang.g4
index a0e4468..33d2de6 100644
--- a/src/main/resources/GeneratedYang.g4
+++ b/src/main/resources/GeneratedYang.g4
@@ -1085,7 +1085,6 @@
      *                             [input-stmt stmtsep]
      *                             [output-stmt stmtsep]
      *                         "}")
-     * TODO : 0..1 occurance to be checked in listener
      */
     rpcStatement : RPC_KEYWORD identifier (STMTEND | LEFT_CURLY_BRACE (ifFeatureStatement | statusStatement | descriptionStatement
                 | referenceStatement | typedefStatement | groupingStatement | inputStatement | outputStatement)* RIGHT_CURLY_BRACE);
@@ -1099,9 +1098,12 @@
      *                           1*(data-def-stmt stmtsep)
      *                         "}"
      */
-    inputStatement : INPUT_KEYWORD LEFT_CURLY_BRACE
-                 ((typedefStatement | groupingStatement)* | dataDefStatement+)
-                 | (dataDefStatement+ | (typedefStatement | groupingStatement)*)RIGHT_CURLY_BRACE;
+    inputStatement : INPUT_KEYWORD LEFT_CURLY_BRACE inputStatementBody RIGHT_CURLY_BRACE;
+
+    inputStatementBody : typedefStatement* dataDefStatement+
+                       | dataDefStatement+ typedefStatement*
+                       | groupingStatement* dataDefStatement+
+                       | dataDefStatement+ groupingStatement*;
 
     /**
      *  output-stmt         = output-keyword optsep
@@ -1112,9 +1114,12 @@
      *                            1*(data-def-stmt stmtsep)
      *                        "}"
      */
-    outputStatement : OUTPUT_KEYWORD LEFT_CURLY_BRACE
-                 ((typedefStatement | groupingStatement)* | dataDefStatement+)
-                 | (dataDefStatement+ | (typedefStatement | groupingStatement)*)RIGHT_CURLY_BRACE;
+    outputStatement : OUTPUT_KEYWORD LEFT_CURLY_BRACE outputStatementBody RIGHT_CURLY_BRACE;
+
+    outputStatementBody : typedefStatement* dataDefStatement+
+                        | dataDefStatement+ typedefStatement*
+                        | groupingStatement* dataDefStatement+
+                        | dataDefStatement+ groupingStatement*;
 
     /**
      *  notification-stmt   = notification-keyword sep
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
new file mode 100644
index 0000000..521b5d0
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangInput;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing Input listener functionality.
+ */
+public class InputListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks input statements with data definition statements as sub-statements.
+     */
+    @Test
+    public void processInputStatementWithDataDefinition() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/InputStatementWithDataDefinition.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("rock"));
+
+        YangRpc yangRpc = (YangRpc) yangNode.getChild();
+        assertThat(yangRpc.getName(), is("activate-software-image"));
+
+        YangInput yangInput = (YangInput) yangRpc.getChild();
+        assertThat(yangInput.getName(), is("activate-software-imageInput"));
+        ListIterator<YangLeaf> leafIterator = yangInput.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("image-name"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+
+        YangList yangList = (YangList) yangInput.getChild();
+        assertThat(yangList.getName(), is("ospf"));
+        assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+        assertThat(yangList.isConfig(), is(true));
+        assertThat(yangList.getMaxElements(), is(10));
+        assertThat(yangList.getMinElements(), is(3));
+        leafIterator = yangList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+
+        YangContainer yangContainer = (YangContainer) yangList.getNextSibling();
+        assertThat(yangContainer.getName(), is("isis"));
+
+        leafIterator = yangContainer.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+    }
+
+    /**
+     * Checks input statements with type-def statement as sub-statements.
+     */
+    @Test
+    public void processInputStatementWithTypedef() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/InputStatementWithTypedef.yang");
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("rock"));
+
+        YangRpc yangRpc = (YangRpc) yangNode.getChild();
+        assertThat(yangRpc.getName(), is("activate-software-image"));
+
+        YangInput yangInput = (YangInput) yangRpc.getChild();
+        assertThat(yangInput.getName(), is("activate-software-imageInput"));
+        YangTypeDef typeDef = (YangTypeDef) yangInput.getChild();
+        assertThat(typeDef.getName(), is("my-type"));
+        assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+        assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32));
+    }
+}
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
new file mode 100644
index 0000000..1702d35
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Test;
+
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing output listener functionality.
+ */
+public class OutputListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks output statements with data definition statements as sub-statements.
+     */
+    @Test
+    public void processOutputStatementWithDataDefinition() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/OutputStatementWithDataDefinition.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("rock"));
+
+        YangRpc yangRpc = (YangRpc) yangNode.getChild();
+        assertThat(yangRpc.getName(), is("activate-software-image"));
+
+        YangOutput yangOutput = (YangOutput) yangRpc.getChild();
+        assertThat(yangOutput.getName(), is("activate-software-imageOutput"));
+        ListIterator<YangLeaf> leafIterator = yangOutput.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("image-name"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
+
+        YangList yangList = (YangList) yangOutput.getChild();
+        assertThat(yangList.getName(), is("ospf"));
+        assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));
+        assertThat(yangList.isConfig(), is(true));
+        assertThat(yangList.getMaxElements(), is(10));
+        assertThat(yangList.getMinElements(), is(3));
+        leafIterator = yangList.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+
+        YangContainer yangContainer = (YangContainer) yangList.getNextSibling();
+        assertThat(yangContainer.getName(), is("isis"));
+
+        leafIterator = yangContainer.getListOfLeaf().listIterator();
+        leafInfo = leafIterator.next();
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
+    }
+
+    /**
+     * Checks output statements with type-def statement as sub-statements.
+     */
+    @Test
+    public void processOutputStatementWithTypedef() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/OutputStatementWithTypedef.yang");
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("rock"));
+
+        YangRpc yangRpc = (YangRpc) yangNode.getChild();
+        assertThat(yangRpc.getName(), is("activate-software-image"));
+
+        YangOutput yangOutput = (YangOutput) yangRpc.getChild();
+        assertThat(yangOutput.getName(), is("activate-software-imageOutput"));
+        YangTypeDef typeDef = (YangTypeDef) yangOutput.getChild();
+        assertThat(typeDef.getName(), is("my-type"));
+        assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+        assertThat(typeDef.getName(), is("my-type"));
+        assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+        assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32));
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
new file mode 100644
index 0000000..9b06c4d
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RpcListenerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing Rpc listener functionality.
+ */
+public class RpcListenerTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks valid rpc statements.
+     */
+    @Test
+    public void processValidRpcStatement() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/ValidRpcStatement.yang");
+
+        assertThat((node instanceof YangModule), is(true));
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("rock"));
+
+        YangRpc yangRpc = (YangRpc) yangNode.getChild();
+        assertThat(yangRpc.getName(), is("rock-the-house"));
+        assertThat(yangRpc.getDescription(), is("\"description\""));
+        assertThat(yangRpc.getReference(), is("\"reference\""));
+        assertThat(yangRpc.getStatus(), is(YangStatusType.CURRENT));
+
+        YangTypeDef typeDef = (YangTypeDef) yangRpc.getChild();
+        assertThat(typeDef.getName(), is("my-type"));
+        assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
+        assertThat(typeDef.getDataType().getDataType(), is(YangDataTypes.INT32));
+    }
+}
diff --git a/src/test/resources/InputStatementWithDataDefinition.yang b/src/test/resources/InputStatementWithDataDefinition.yang
new file mode 100644
index 0000000..0adf3d3
--- /dev/null
+++ b/src/test/resources/InputStatementWithDataDefinition.yang
@@ -0,0 +1,28 @@
+module rock {
+    namespace "http://example.net/rock";
+    prefix "rock";
+
+    rpc activate-software-image {
+        description "description";
+        input {
+            leaf image-name {
+                type string;
+            }
+            list ospf {
+                key "invalid-interval";
+                config true;
+                max-elements 10;
+                min-elements 3;
+                leaf invalid-interval {
+                    type uint16;
+                }
+            }
+            container isis {
+               config true;
+               leaf invalid-interval {
+                   type uint16;
+               }
+           }
+        }
+    }
+}
diff --git a/src/test/resources/InputStatementWithTypedef.yang b/src/test/resources/InputStatementWithTypedef.yang
new file mode 100644
index 0000000..25ca73d
--- /dev/null
+++ b/src/test/resources/InputStatementWithTypedef.yang
@@ -0,0 +1,17 @@
+module rock {
+    namespace "http://example.net/rock";
+    prefix "rock";
+
+    rpc activate-software-image {
+        description "description";
+        input {
+            leaf image-name {
+                type string;
+            }
+            typedef my-type {
+                status deprecated;
+                type int32;
+            }
+        }
+    }
+}
diff --git a/src/test/resources/OutputStatementWithDataDefinition.yang b/src/test/resources/OutputStatementWithDataDefinition.yang
new file mode 100644
index 0000000..527b399
--- /dev/null
+++ b/src/test/resources/OutputStatementWithDataDefinition.yang
@@ -0,0 +1,28 @@
+module rock {
+    namespace "http://example.net/rock";
+    prefix "rock";
+
+    rpc activate-software-image {
+        description "description";
+        output {
+            leaf image-name {
+                type string;
+            }
+            list ospf {
+                key "invalid-interval";
+                config true;
+                max-elements 10;
+                min-elements 3;
+                leaf invalid-interval {
+                    type uint16;
+                }
+            }
+            container isis {
+               config true;
+               leaf invalid-interval {
+                   type uint16;
+               }
+           }
+        }
+    }
+}
diff --git a/src/test/resources/OutputStatementWithTypedef.yang b/src/test/resources/OutputStatementWithTypedef.yang
new file mode 100644
index 0000000..6027c2d
--- /dev/null
+++ b/src/test/resources/OutputStatementWithTypedef.yang
@@ -0,0 +1,17 @@
+module rock {
+    namespace "http://example.net/rock";
+    prefix "rock";
+
+    rpc activate-software-image {
+        description "description";
+        output {
+            leaf image-name {
+                type string;
+            }
+            typedef my-type {
+                status deprecated;
+                type int32;
+            }
+        }
+    }
+}
diff --git a/src/test/resources/ValidRpcStatement.yang b/src/test/resources/ValidRpcStatement.yang
new file mode 100644
index 0000000..f188227
--- /dev/null
+++ b/src/test/resources/ValidRpcStatement.yang
@@ -0,0 +1,24 @@
+module rock {
+    namespace "http://example.net/rock";
+    prefix "rock";
+
+    rpc rock-the-house {
+        description "description";
+        status current;
+        reference "reference";
+        typedef my-type {
+           status deprecated;
+           type int32;
+        }
+        input {
+            leaf zip-code {
+                type string;
+            }
+        }
+        output {
+             leaf status {
+                 type string;
+             }
+        }
+    }
+}