Revision: 19765
          http://sourceforge.net/p/gate/code/19765
Author:   ian_roberts
Date:     2016-11-21 18:32:52 +0000 (Mon, 21 Nov 2016)
Log Message:
-----------
Made the newline character on the end of a single-line comment optional, to 
allow for comments on the very last line of a file (with no trailing newline).

Modified Paths:
--------------
    gate/trunk/src/main/gate/jape/parser/ParseCpsl.jj
    gate/trunk/src/main/gate/jape/parser/ParseCpslPlain.html
    gate/trunk/src/main/gate/jape/parser/ParseCpslTokenManager.java

Modified: gate/trunk/src/main/gate/jape/parser/ParseCpsl.jj
===================================================================
--- gate/trunk/src/main/gate/jape/parser/ParseCpsl.jj   2016-11-21 17:15:02 UTC 
(rev 19764)
+++ gate/trunk/src/main/gate/jape/parser/ParseCpsl.jj   2016-11-21 18:32:52 UTC 
(rev 19765)
@@ -408,10 +408,10 @@
   <phasesWhiteSpace: (<space>)+>
 }
 <IN_PHASES> SPECIAL_TOKEN: { // single-line C++/Java style comments
-  <phasesSingleLineCStyleComment: "//" (~["\n", "\r"])* <newline> >
+  <phasesSingleLineCStyleComment: "//" (~["\n", "\r"])* (<newline>)? >
 }
 <IN_PHASES> SPECIAL_TOKEN: { // single-line comments CPSL style
-  <phasesSingleLineCpslStyleComment: ";;" (~["\n", "\r"])* <newline> >
+  <phasesSingleLineCpslStyleComment: ";;" (~["\n", "\r"])* (<newline>)? >
 }
 <IN_PHASES> SPECIAL_TOKEN: {
   <phasesCommentStart: ("/*" | "#|")> : PHASES_WITHIN_COMMENT
@@ -526,10 +526,10 @@
   <whiteSpace: (<space>)+>
 }
 <DEFAULT> SPECIAL_TOKEN: { // single-line C++/Java style comments
-  <singleLineCStyleComment: "//" (~["\n", "\r"])* <newline> >
+  <singleLineCStyleComment: "//" (~["\n", "\r"])* (<newline>)? >
 }
 <DEFAULT> SPECIAL_TOKEN: { // single-line comments CPSL style
-  <singleLineCpslStyleComment: ";;" (~["\n", "\r"])* <newline> >
+  <singleLineCpslStyleComment: ";;" (~["\n", "\r"])* (<newline>)? >
 }
 <DEFAULT> SPECIAL_TOKEN: { <commentStart: ("/*" | "#|")> : WITHIN_COMMENT }
 <WITHIN_COMMENT> MORE: { <commentChars: ~[]> }

Modified: gate/trunk/src/main/gate/jape/parser/ParseCpslPlain.html
===================================================================
--- gate/trunk/src/main/gate/jape/parser/ParseCpslPlain.html    2016-11-21 
17:15:02 UTC (rev 19764)
+++ gate/trunk/src/main/gate/jape/parser/ParseCpslPlain.html    2016-11-21 
18:32:52 UTC (rev 19765)
@@ -197,7 +197,7 @@
   <TD>
    <PRE>
 &lt;IN_PHASES&gt; SPECIAL : {
-&lt;phasesSingleLineCStyleComment: "//" (~["\n","\r"])* &lt;newline&gt;&gt;
+&lt;phasesSingleLineCStyleComment: "//" (~["\n","\r"])* (&lt;newline&gt;)?&gt;
 }
 
    </PRE>
@@ -208,7 +208,7 @@
   <TD>
    <PRE>
 &lt;IN_PHASES&gt; SPECIAL : {
-&lt;phasesSingleLineCpslStyleComment: ";;" (~["\n","\r"])* &lt;newline&gt;&gt;
+&lt;phasesSingleLineCpslStyleComment: ";;" (~["\n","\r"])* 
(&lt;newline&gt;)?&gt;
 }
 
    </PRE>
@@ -709,7 +709,7 @@
   <TD>
    <PRE>
 &lt;DEFAULT&gt; SPECIAL : {
-&lt;singleLineCStyleComment: "//" (~["\n","\r"])* &lt;newline&gt;&gt;
+&lt;singleLineCStyleComment: "//" (~["\n","\r"])* (&lt;newline&gt;)?&gt;
 }
 
    </PRE>
@@ -720,7 +720,7 @@
   <TD>
    <PRE>
 &lt;DEFAULT&gt; SPECIAL : {
-&lt;singleLineCpslStyleComment: ";;" (~["\n","\r"])* &lt;newline&gt;&gt;
+&lt;singleLineCpslStyleComment: ";;" (~["\n","\r"])* (&lt;newline&gt;)?&gt;
 }
 
    </PRE>

Modified: gate/trunk/src/main/gate/jape/parser/ParseCpslTokenManager.java
===================================================================
--- gate/trunk/src/main/gate/jape/parser/ParseCpslTokenManager.java     
2016-11-21 17:15:02 UTC (rev 19764)
+++ gate/trunk/src/main/gate/jape/parser/ParseCpslTokenManager.java     
2016-11-21 18:32:52 UTC (rev 19765)
@@ -854,12 +854,18 @@
                   { jjCheckNAdd(21); }
                   break;
                case 22:
-                  if (curChar == 59)
-                     { jjCheckNAddStates(22, 25); }
+                  if (curChar != 59)
+                     break;
+                  if (kind > 67)
+                     kind = 67;
+                  { jjCheckNAddStates(22, 25); }
                   break;
                case 23:
-                  if ((0xffffffffffffdbffL & l) != 0L)
-                     { jjCheckNAddStates(22, 25); }
+                  if ((0xffffffffffffdbffL & l) == 0L)
+                     break;
+                  if (kind > 67)
+                     kind = 67;
+                  { jjCheckNAddStates(22, 25); }
                   break;
                case 24:
                   if ((0x2400L & l) != 0L && kind > 67)
@@ -985,12 +991,18 @@
                      { jjAddStates(11, 12); }
                   break;
                case 56:
-                  if (curChar == 47)
-                     { jjCheckNAddStates(39, 42); }
+                  if (curChar != 47)
+                     break;
+                  if (kind > 66)
+                     kind = 66;
+                  { jjCheckNAddStates(39, 42); }
                   break;
                case 57:
-                  if ((0xffffffffffffdbffL & l) != 0L)
-                     { jjCheckNAddStates(39, 42); }
+                  if ((0xffffffffffffdbffL & l) == 0L)
+                     break;
+                  if (kind > 66)
+                     kind = 66;
+                  { jjCheckNAddStates(39, 42); }
                   break;
                case 58:
                   if ((0x2400L & l) != 0L && kind > 66)
@@ -1088,6 +1100,8 @@
                      kind = 50;
                   break;
                case 23:
+                  if (kind > 67)
+                     kind = 67;
                   { jjAddStates(22, 25); }
                   break;
                case 30:
@@ -1111,6 +1125,8 @@
                      { jjAddStates(49, 50); }
                   break;
                case 57:
+                  if (kind > 66)
+                     kind = 66;
                   { jjAddStates(39, 42); }
                   break;
                default : break;
@@ -1129,12 +1145,18 @@
             switch(jjstateSet[--i])
             {
                case 23:
-                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
-                     { jjAddStates(22, 25); }
+                  if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+                     break;
+                  if (kind > 67)
+                     kind = 67;
+                  { jjAddStates(22, 25); }
                   break;
                case 57:
-                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
-                     { jjAddStates(39, 42); }
+                  if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+                     break;
+                  if (kind > 66)
+                     kind = 66;
+                  { jjAddStates(39, 42); }
                   break;
                default : if (i1 == 0 || l1 == 0 || i2 == 0 ||  l2 == 0) break; 
else break;
             }
@@ -1417,12 +1439,18 @@
                   { jjCheckNAdd(1); }
                   break;
                case 2:
-                  if (curChar == 59)
-                     { jjCheckNAddStates(53, 56); }
+                  if (curChar != 59)
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  { jjCheckNAddStates(53, 56); }
                   break;
                case 3:
-                  if ((0xffffffffffffdbffL & l) != 0L)
-                     { jjCheckNAddStates(53, 56); }
+                  if ((0xffffffffffffdbffL & l) == 0L)
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  { jjCheckNAddStates(53, 56); }
                   break;
                case 4:
                   if ((0x2400L & l) != 0L && kind > 16)
@@ -1453,12 +1481,18 @@
                      { jjAddStates(51, 52); }
                   break;
                case 13:
-                  if (curChar == 47)
-                     { jjCheckNAddStates(57, 60); }
+                  if (curChar != 47)
+                     break;
+                  if (kind > 15)
+                     kind = 15;
+                  { jjCheckNAddStates(57, 60); }
                   break;
                case 14:
-                  if ((0xffffffffffffdbffL & l) != 0L)
-                     { jjCheckNAddStates(57, 60); }
+                  if ((0xffffffffffffdbffL & l) == 0L)
+                     break;
+                  if (kind > 15)
+                     kind = 15;
+                  { jjCheckNAddStates(57, 60); }
                   break;
                case 15:
                   if ((0x2400L & l) != 0L && kind > 15)
@@ -1504,6 +1538,8 @@
                   { jjCheckNAdd(0); }
                   break;
                case 3:
+                  if (kind > 16)
+                     kind = 16;
                   { jjAddStates(53, 56); }
                   break;
                case 10:
@@ -1511,6 +1547,8 @@
                      kind = 17;
                   break;
                case 14:
+                  if (kind > 15)
+                     kind = 15;
                   { jjAddStates(57, 60); }
                   break;
                default : break;
@@ -1529,12 +1567,18 @@
             switch(jjstateSet[--i])
             {
                case 3:
-                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
-                     { jjAddStates(53, 56); }
+                  if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+                     break;
+                  if (kind > 16)
+                     kind = 16;
+                  { jjAddStates(53, 56); }
                   break;
                case 14:
-                  if (jjCanMove_0(hiByte, i1, i2, l1, l2))
-                     { jjAddStates(57, 60); }
+                  if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+                     break;
+                  if (kind > 15)
+                     kind = 15;
+                  { jjAddStates(57, 60); }
                   break;
                default : if (i1 == 0 || l1 == 0 || i2 == 0 ||  l2 == 0) break; 
else break;
             }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to