ONOS-6678 YANG Compiler: Comments after module end and {\ to be handled

* add an exclusion of '}' in STRING token
* add a test case which has '}//' token

Change-Id: I4d74a496eeaa9b6d4600f09377ff3b57aaf1d4a5
diff --git a/compiler/base/parser/src/main/resources/YangLexer.g4 b/compiler/base/parser/src/main/resources/YangLexer.g4
index 792a2cb..d020371 100644
--- a/compiler/base/parser/src/main/resources/YangLexer.g4
+++ b/compiler/base/parser/src/main/resources/YangLexer.g4
@@ -126,7 +126,7 @@
     WS  :   [ \r\t\u000C\n]+ -> channel(HIDDEN)
         ;
     LINE_COMMENT
-        : '//' ~[\r\n]* '\r'? '\n' -> channel(HIDDEN)
+        : '//' ~[\r\n]* -> channel(HIDDEN)
         ;
 
     // Additional rules
@@ -144,7 +144,7 @@
 
     UNKNOWN_STATEMENT : IDENTIFIER COLON IDENTIFIER;
 
-    STRING : ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '+' | '\'')~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '+')* ) | SUB_STRING );
+    STRING : ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '}' | '"' | '+' | '\'')~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '+')* ) | SUB_STRING );
 
     //Fragment rules
     fragment SUB_STRING : ('"' (ESC | ~["])*'"') | ('\'' (ESC | ~['])*'\'') ;
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListenerTest.java
index d199b38..302915c 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/TreeWalkListenerTest.java
@@ -19,6 +19,7 @@
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.onosproject.yang.compiler.datamodel.YangNode;
 import org.onosproject.yang.compiler.parser.exceptions.ParserException;
 
 import java.io.IOException;
@@ -80,4 +81,9 @@
         thrown.expectMessage("mismatched input 'container' expecting <EOF>");
         manager.getDataModel("src/test/resources/ProcessFileWithExtraBraceInBetween.yang");
     }
+
+    @Test
+    public void processRightBraceComment() throws IOException, ParserException {
+        YangNode node = manager.getDataModel("src/test/resources/RightBraceComment.yang");
+    }
 }
diff --git a/compiler/base/parser/src/test/resources/RightBraceComment.yang b/compiler/base/parser/src/test/resources/RightBraceComment.yang
new file mode 100644
index 0000000..b6f581d
--- /dev/null
+++ b/compiler/base/parser/src/test/resources/RightBraceComment.yang
@@ -0,0 +1,32 @@
+module test {
+    namespace "test:test";
+    prefix test;
+    typedef type1 {
+        type string;
+    }
+    list list1 {
+       key "name sur-name";
+       leaf name {
+          type string;
+       }
+       leaf sur-name {
+           type type1;
+       }
+       choice c1 {
+          case ca1 {
+             leaf a {
+                type int32;
+             }
+          }
+       }
+    }
+    list list2 {
+           key "name sur-name";
+           leaf name {
+              type string;
+           }
+           leaf sur-name {
+               type type1;
+           }
+        }
+}//module
\ No newline at end of file