You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/10/28 15:05:19 UTC

[GitHub] tmysik closed pull request #989: [NETBEANS-1563] Error while parsing HEREDOC

tmysik closed pull request #989: [NETBEANS-1563] Error while parsing HEREDOC
URL: https://github.com/apache/incubator-netbeans/pull/989
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/lexer/PHP5ColoringLexer.java b/php/php.editor/src/org/netbeans/modules/php/editor/lexer/PHP5ColoringLexer.java
index 56b02612f7..c7b3657f6c 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/lexer/PHP5ColoringLexer.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/lexer/PHP5ColoringLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 18/09/19 21:14 */
+/* The following code was generated by JFlex 1.4.3 on 18/10/28 6:33 */
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -30,7 +30,7 @@
 /**
  * This class is a scanner generated by
  * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 18/09/19 21:14 from the specification file
+ * on 18/10/28 6:33 from the specification file
  * <tt>/home/junichi11/NetBeansProjects/incubator-netbeans/php/php.editor/tools/Php5ColoringScanner.flex</tt>
  */
 public class PHP5ColoringLexer {
@@ -185,45 +185,45 @@
     "\4\5\1\7\1\4\1\10\1\4\1\11\1\12\1\13"+
     "\1\14\14\6\1\4\23\5\1\2\1\4\1\15\2\5"+
     "\1\4\2\5\1\16\1\17\1\20\1\21\1\22\2\21"+
-    "\1\20\3\21\3\23\1\24\1\23\4\21\1\2\1\21"+
-    "\1\25\1\26\1\25\1\27\1\2\1\30\1\2\2\30"+
-    "\3\31\1\32\1\0\2\2\1\33\1\34\1\33\1\35"+
-    "\2\36\1\3\1\37\1\3\1\40\1\37\1\41\4\0"+
-    "\4\42\2\43\1\44\1\45\1\46\1\0\1\47\1\50"+
-    "\1\0\1\3\2\0\6\5\1\51\2\0\4\5\1\0"+
-    "\1\5\1\0\1\52\2\0\1\21\2\0\2\6\1\0"+
-    "\1\53\1\54\1\55\1\56\4\5\1\57\4\5\1\60"+
-    "\1\5\1\61\33\5\13\0\2\5\1\62\1\5\3\0"+
-    "\2\63\2\64\1\65\1\66\1\64\3\0\1\63\2\64"+
-    "\1\67\1\70\3\0\1\71\1\0\1\26\1\0\1\27"+
-    "\3\0\1\72\1\0\1\30\2\73\1\0\1\32\1\0"+
-    "\1\74\2\0\1\75\1\63\1\0\1\76\1\0\1\77"+
-    "\1\100\1\42\1\101\1\102\3\0\7\5\2\3\1\103"+
-    "\3\5\1\0\1\5\3\0\4\5\1\104\4\5\1\105"+
-    "\3\5\1\106\5\5\1\107\13\5\1\110\14\5\1\111"+
-    "\12\0\12\5\3\112\1\113\1\0\1\114\1\0\1\71"+
-    "\1\72\1\115\1\116\1\42\2\0\1\117\6\5\1\120"+
-    "\1\121\1\122\6\5\4\0\1\123\5\5\1\124\11\5"+
-    "\1\125\2\5\1\126\1\5\1\127\3\5\1\130\1\5"+
-    "\1\131\1\132\4\5\1\133\10\5\12\0\13\5\1\113"+
-    "\1\42\1\134\1\0\3\5\1\135\3\5\1\136\1\5"+
-    "\1\137\1\140\1\5\1\141\2\142\3\0\3\5\1\143"+
-    "\10\5\1\144\1\5\1\145\1\146\1\147\6\5\1\150"+
-    "\1\151\1\5\1\152\1\153\1\5\1\154\3\5\1\155"+
-    "\10\0\1\156\1\0\1\157\1\160\11\5\1\42\1\0"+
-    "\1\5\1\161\3\5\1\162\3\5\3\0\1\163\13\5"+
-    "\1\164\1\165\1\166\1\167\1\170\4\5\1\171\1\172"+
-    "\5\0\11\5\1\42\1\1\1\173\4\5\1\174\1\175"+
-    "\1\5\2\176\1\0\1\177\2\5\1\200\1\201\3\5"+
-    "\1\202\5\5\1\203\3\0\3\5\1\204\5\5\1\42"+
-    "\1\0\3\5\1\205\1\206\1\0\1\5\1\207\5\5"+
-    "\1\210\1\5\1\211\1\212\1\5\1\0\1\213\3\5"+
-    "\1\214\3\5\1\42\1\0\2\5\1\215\1\46\1\5"+
-    "\1\216\1\217\1\220\3\5\1\221\1\0\2\5\1\222"+
-    "\1\223\2\5\1\42\1\0\1\224\1\225\1\5\1\226"+
-    "\1\5\1\227\1\230\3\5\1\231\1\42\1\0\5\5"+
-    "\1\0\1\232\1\233\1\234\2\5\1\0\1\235\1\5"+
-    "\1\0\1\5\1\0\1\236\14\0\1\237\1\0";
+    "\1\20\3\21\3\23\1\24\1\23\3\25\1\21\1\2"+
+    "\1\21\1\26\1\27\1\26\1\30\1\2\1\31\1\2"+
+    "\2\31\3\32\1\33\1\0\2\2\1\34\1\35\1\34"+
+    "\1\36\2\37\1\3\1\40\1\3\1\41\1\40\1\42"+
+    "\4\0\4\43\2\44\1\45\1\46\1\47\1\0\1\50"+
+    "\1\51\1\0\1\3\2\0\6\5\1\52\2\0\4\5"+
+    "\1\0\1\5\1\0\1\53\2\0\1\21\2\0\2\6"+
+    "\1\0\1\54\1\55\1\56\1\57\4\5\1\60\4\5"+
+    "\1\61\1\5\1\62\33\5\13\0\2\5\1\63\1\5"+
+    "\3\0\2\64\2\65\1\66\1\67\1\65\3\0\1\64"+
+    "\2\65\1\70\1\71\3\0\1\72\1\0\1\27\1\0"+
+    "\1\30\3\0\1\73\1\0\1\31\2\74\1\0\1\33"+
+    "\1\0\1\75\2\0\1\76\1\64\1\0\1\77\1\0"+
+    "\1\100\1\101\1\43\1\102\1\103\3\0\7\5\2\3"+
+    "\1\104\3\5\1\0\1\5\3\0\4\5\1\105\4\5"+
+    "\1\106\3\5\1\107\5\5\1\110\13\5\1\111\14\5"+
+    "\1\112\12\0\12\5\3\113\1\114\1\0\1\115\1\0"+
+    "\1\72\1\73\1\116\1\117\1\43\2\0\1\120\6\5"+
+    "\1\121\1\122\1\123\6\5\4\0\1\124\5\5\1\125"+
+    "\11\5\1\126\2\5\1\127\1\5\1\130\3\5\1\131"+
+    "\1\5\1\132\1\133\4\5\1\134\10\5\12\0\13\5"+
+    "\1\114\1\43\1\135\1\0\3\5\1\136\3\5\1\137"+
+    "\1\5\1\140\1\141\1\5\1\142\2\143\3\0\3\5"+
+    "\1\144\10\5\1\145\1\5\1\146\1\147\1\150\6\5"+
+    "\1\151\1\152\1\5\1\153\1\154\1\5\1\155\3\5"+
+    "\1\156\10\0\1\157\1\0\1\160\1\161\11\5\1\43"+
+    "\1\0\1\5\1\162\3\5\1\163\3\5\3\0\1\164"+
+    "\13\5\1\165\1\166\1\167\1\170\1\171\4\5\1\172"+
+    "\1\173\5\0\11\5\1\43\1\1\1\174\4\5\1\175"+
+    "\1\176\1\5\2\177\1\0\1\200\2\5\1\201\1\202"+
+    "\3\5\1\203\5\5\1\204\3\0\3\5\1\205\5\5"+
+    "\1\43\1\0\3\5\1\206\1\207\1\0\1\5\1\210"+
+    "\5\5\1\211\1\5\1\212\1\213\1\5\1\0\1\214"+
+    "\3\5\1\215\3\5\1\43\1\0\2\5\1\216\1\47"+
+    "\1\5\1\217\1\220\1\221\3\5\1\222\1\0\2\5"+
+    "\1\223\1\224\2\5\1\43\1\0\1\225\1\226\1\5"+
+    "\1\227\1\5\1\230\1\231\3\5\1\232\1\43\1\0"+
+    "\5\5\1\0\1\233\1\234\1\235\2\5\1\0\1\236"+
+    "\1\5\1\0\1\5\1\0\1\237\14\0\1\240\1\0";
 
   private static int [] zzUnpackAction() {
     int [] result = new int[732];
@@ -1912,21 +1912,21 @@ public PHPTokenId nextToken() throws java.io.IOException {
       }
 
       switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
-        case 31:
+        case 32:
           { //the difference from the original rules comes from the fact that we took ';' out out of tokens
     return  PHPTokenId.UNKNOWN_TOKEN;
           }
-        case 160: break;
-        case 95:
+        case 161: break;
+        case 96:
           { return PHPTokenId.PHP_FALSE;
           }
-        case 161: break;
-        case 25:
+        case 162: break;
+        case 26:
           { yypushback(1);
     yybegin(ST_PHP_NOWDOC);
           }
-        case 162: break;
-        case 34:
+        case 163: break;
+        case 35:
           { String yytext = yytext();
     switch (yytext.charAt(yytext.length() - 1)) {
         case '?':
@@ -1938,12 +1938,12 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
      return PHPTokenId.PHP_LINE_COMMENT;
           }
-        case 163: break;
-        case 76:
+        case 164: break;
+        case 77:
           { yypushback(2);
         return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
           }
-        case 164: break;
+        case 165: break;
         case 4:
           { if(isInConst) {
         // for checking arrays
@@ -1968,25 +1968,25 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
     return PHPTokenId.PHP_TOKEN;
           }
-        case 165: break;
-        case 63:
+        case 166: break;
+        case 64:
           { popState();
     return PHPTokenId.PHPDOC_COMMENT_END;
           }
-        case 166: break;
-        case 130:
+        case 167: break;
+        case 131:
           { return PHPTokenId.PHP_INCLUDE;
           }
-        case 167: break;
-        case 149:
+        case 168: break;
+        case 150:
           { return PHPTokenId.PHP_ENDDECLARE;
           }
-        case 168: break;
-        case 36:
+        case 169: break;
+        case 37:
           { return  PHPTokenId.UNKNOWN_TOKEN;
           }
-        case 169: break;
-        case 58:
+        case 170: break;
+        case 59:
           { /* <ST_PHP_NOWDOC>{NEWLINE}{TABS_AND_SPACES}{LABEL}";"?[^\n\r]*[\r\n]? */
         if (isEndNowdoc()) {
             String yytext = yytext();
@@ -2003,21 +2003,21 @@ public PHPTokenId nextToken() throws java.io.IOException {
             yypushback(1); // [\r\n] length
         }
           }
-        case 170: break;
-        case 120:
+        case 171: break;
+        case 121:
           { return PHPTokenId.PHP_GLOBAL;
           }
-        case 171: break;
-        case 156:
+        case 172: break;
+        case 157:
           { return PHPTokenId.PHP__FUNCTION__;
           }
-        case 172: break;
+        case 173: break;
         case 18:
           { popState();
     return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
           }
-        case 173: break;
-        case 40:
+        case 174: break;
+        case 41:
           { if (shortTagsAllowed ) {
         //yybegin(ST_PHP_IN_SCRIPTING);
         pushState(ST_PHP_IN_SCRIPTING);
@@ -2028,39 +2028,39 @@ public PHPTokenId nextToken() throws java.io.IOException {
         return PHPTokenId.T_INLINE_HTML;
     }
           }
-        case 174: break;
-        case 54:
+        case 175: break;
+        case 55:
           { yypushback(1);
     pushState(ST_PHP_IN_SCRIPTING);
     return PHPTokenId.PHP_CURLY_OPEN;
           }
-        case 175: break;
-        case 116:
+        case 176: break;
+        case 117:
           { return PHPTokenId.PHP_TYPE_OBJECT;
           }
-        case 176: break;
-        case 86:
+        case 177: break;
+        case 87:
           { return PHPTokenId.PHP_LIST;
           }
-        case 177: break;
-        case 94:
+        case 178: break;
+        case 95:
           { return PHPTokenId.PHP_EMPTY;
           }
-        case 178: break;
+        case 179: break;
         case 15:
           { pushState(ST_PHP_LINE_COMMENT);
     return PHPTokenId.PHP_LINE_COMMENT;
           }
-        case 179: break;
-        case 91:
+        case 180: break;
+        case 92:
           { return PHPTokenId.PHP_CASE;
           }
-        case 180: break;
-        case 42:
+        case 181: break;
+        case 43:
           { return PHPTokenId.PHP_VARIABLE;
           }
-        case 181: break;
-        case 45:
+        case 182: break;
+        case 46:
           { //popState();
         yybegin(YYINITIAL);
         if (yylength() > 2) {
@@ -2069,8 +2069,8 @@ public PHPTokenId nextToken() throws java.io.IOException {
         stack.clear();
     return PHPTokenId.PHP_CLOSETAG;
           }
-        case 182: break;
-        case 22:
+        case 183: break;
+        case 23:
           { int trailingNewLineLength = 1;
         int label_len = yylength() - trailingNewLineLength;
         int back = trailingNewLineLength;
@@ -2090,7 +2090,7 @@ public PHPTokenId nextToken() throws java.io.IOException {
             yybegin(ST_PHP_HEREDOC);
         }
           }
-        case 183: break;
+        case 184: break;
         case 8:
           { if(isInConst) {
         isInConst = false;
@@ -2099,8 +2099,8 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
     return PHPTokenId.PHP_SEMICOLON;
           }
-        case 184: break;
-        case 44:
+        case 185: break;
+        case 45:
           { if (aspTagsAllowed) {
             yybegin(YYINITIAL);
             stack.clear();
@@ -2108,36 +2108,36 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
     return  PHPTokenId.UNKNOWN_TOKEN;
           }
-        case 185: break;
-        case 35:
+        case 186: break;
+        case 36:
           { return PHPTokenId.PHP_LINE_COMMENT;
           }
-        case 186: break;
-        case 83:
+        case 187: break;
+        case 84:
           { pushState(ST_PHP_DOC_COMMENT);
     yypushback(yylength()-3);
     return PHPTokenId.PHPDOC_COMMENT_START;
           }
-        case 187: break;
-        case 100:
+        case 188: break;
+        case 101:
           { return PHPTokenId.PHP_ISSET;
           }
-        case 188: break;
-        case 139:
+        case 189: break;
+        case 140:
           { return PHPTokenId.PHP__FILE__;
           }
-        case 189: break;
-        case 49:
+        case 190: break;
+        case 50:
           { return PHPTokenId.PHP_IF;
           }
-        case 190: break;
-        case 55:
+        case 191: break;
+        case 56:
           { popState();
     pushState(ST_PHP_LOOKING_FOR_PROPERTY);
     return PHPTokenId.PHP_OBJECT_OPERATOR;
           }
-        case 191: break;
-        case 65:
+        case 192: break;
+        case 66:
           { if (aspTagsAllowed) {
             yybegin(YYINITIAL);
             stack.clear();
@@ -2149,12 +2149,12 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
     return PHPTokenId.PHP_LINE_COMMENT;
           }
-        case 192: break;
-        case 47:
+        case 193: break;
+        case 48:
           { return PHPTokenId.PHP_AS;
           }
-        case 193: break;
-        case 23:
+        case 194: break;
+        case 24:
           { heredoc=null;
     hereocLength=0;
     yybegin(ST_PHP_IN_SCRIPTING);
@@ -2166,62 +2166,34 @@ public PHPTokenId nextToken() throws java.io.IOException {
     yypushback(back);
     return PHPTokenId.PHP_HEREDOC_TAG_END;
           }
-        case 194: break;
-        case 158:
+        case 195: break;
+        case 159:
           { pushState(ST_HALTED_COMPILER);
     return PHPTokenId.PHP_HALT_COMPILER;
           }
-        case 195: break;
-        case 73:
-          { return PHPTokenId.PHP_USE;
-          }
         case 196: break;
-        case 103:
-          { return PHPTokenId.PHP_TYPE_FLOAT;
+        case 74:
+          { return PHPTokenId.PHP_USE;
           }
         case 197: break;
-        case 57:
-          { /* {NEWLINE}{TABS_AND_SPACES}{LABEL}";"?[^\n\r]*[\n\r]? */
-        int trailingNewLineLength = 1;
-        if (isEndHeredoc()) {
-            String yytext = yytext();
-            int newlineLength = yytext.startsWith("\r\n") ? 2 : 1;
-            int back = yylength() - newlineLength;
-            yypushback(back);
-            yybegin(ST_PHP_END_HEREDOC);
-        } else {
-            int indexOfVariable1 = yytext().indexOf("$");
-            int indexOfVariable2 = yytext().indexOf("{$");
-            if (indexOfVariable1 > 0 && indexOfVariable2 == -1) {
-                yypushback(yylength() - indexOfVariable1);
-                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
-            } else if (indexOfVariable2 > 0 && indexOfVariable1 == -1) {
-                yypushback(yylength() - indexOfVariable2);
-                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
-            } else if (indexOfVariable1 > 0 && indexOfVariable2 > 0) {
-                yypushback(yylength() - Math.min(indexOfVariable1, indexOfVariable2));
-                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
-            } else {
-                yypushback(trailingNewLineLength);
-            }
-        }
-        return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
+        case 104:
+          { return PHPTokenId.PHP_TYPE_FLOAT;
           }
         case 198: break;
-        case 157:
+        case 158:
           { return PHPTokenId.PHP__NAMESPACE__;
           }
         case 199: break;
-        case 64:
+        case 65:
           { popState();
     return PHPTokenId.PHP_LINE_COMMENT;
           }
         case 200: break;
-        case 155:
+        case 156:
           { return PHPTokenId.PHP_INCLUDE_ONCE;
           }
         case 201: break;
-        case 142:
+        case 143:
           { return PHPTokenId.PHP_NAMESPACE;
           }
         case 202: break;
@@ -2232,16 +2204,16 @@ public PHPTokenId nextToken() throws java.io.IOException {
     return PHPTokenId.PHP_TOKEN;
           }
         case 203: break;
-        case 62:
+        case 63:
           { popState();
     return PHPTokenId.PHP_COMMENT_END;
           }
         case 204: break;
-        case 136:
+        case 137:
           { return PHPTokenId.PHP_ITERABLE;
           }
         case 205: break;
-        case 98:
+        case 99:
           { int bprefix = (yytext().charAt(0) != '<') ? 1 : 0;
     int startString=3+bprefix;
     hereocLength = yylength()-bprefix-3-1-(yytext().charAt(yylength()-2)=='\r'?1:0);
@@ -2259,7 +2231,7 @@ public PHPTokenId nextToken() throws java.io.IOException {
     return PHPTokenId.PHP_HEREDOC_TAG_START;
           }
         case 206: break;
-        case 61:
+        case 62:
           { // const keyword is also used within group uses. so check "=", otherwise it matches the following:
     // use A\{const CONSTANTA, function myFunction,...}
     popState();
@@ -2274,7 +2246,7 @@ public PHPTokenId nextToken() throws java.io.IOException {
     return PHPTokenId.PHP_STRING;
           }
         case 207: break;
-        case 38:
+        case 39:
           { popState();
     return PHPTokenId.T_INLINE_HTML;
           }
@@ -2288,7 +2260,7 @@ public PHPTokenId nextToken() throws java.io.IOException {
     return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
           }
         case 210: break;
-        case 51:
+        case 52:
           { pushState(ST_PHP_QUOTES_AFTER_VARIABLE);
     return PHPTokenId.PHP_VARIABLE;
           }
@@ -2297,43 +2269,43 @@ public PHPTokenId nextToken() throws java.io.IOException {
           { return PHPTokenId.PHP_NUMBER;
           }
         case 212: break;
-        case 74:
+        case 75:
           { yypushback(1);
     pushState(ST_PHP_VAR_OFFSET);
     return PHPTokenId.PHP_VARIABLE;
           }
         case 213: break;
-        case 127:
+        case 128:
           { return PHPTokenId.PHP_REQUIRE;
           }
         case 214: break;
-        case 129:
+        case 130:
           { return PHPTokenId.PHP_DECLARE;
           }
         case 215: break;
-        case 106:
+        case 107:
           { return PHPTokenId.PHP_CLONE;
           }
         case 216: break;
-        case 101:
+        case 102:
           { return PHPTokenId.PHP_TRAIT;
           }
         case 217: break;
-        case 53:
+        case 54:
           { pushState(ST_PHP_IN_SCRIPTING);
     return PHPTokenId.PHP_TOKEN;
           }
         case 218: break;
-        case 68:
+        case 69:
           { return PHPTokenId.PHP_NEW;
           }
         case 219: break;
-        case 77:
+        case 78:
           { yypushback(2);
     return PHPTokenId.PHP_COMMENT;
           }
         case 220: break;
-        case 60:
+        case 61:
           { return PHPTokenId.PHP_OBJECT_OPERATOR;
           }
         case 221: break;
@@ -2342,30 +2314,30 @@ public PHPTokenId nextToken() throws java.io.IOException {
         popState();
           }
         case 222: break;
-        case 123:
+        case 124:
           { return PHPTokenId.PHP_EXTENDS;
           }
         case 223: break;
-        case 84:
+        case 85:
           { return PHPTokenId.PHP_NULL;
           }
         case 224: break;
-        case 92:
+        case 93:
           { pushState(ST_PHP_IN_SCRIPTING);
     //yybegin(ST_PHP_IN_SCRIPTING);
     return PHPTokenId.PHP_OPENTAG;
     //return createSymbol(ASTSymbol.T_OPEN_TAG);
           }
         case 225: break;
-        case 112:
+        case 113:
           { return PHPTokenId.PHP_WHILE;
           }
         case 226: break;
-        case 141:
+        case 142:
           { return PHPTokenId.PHP_ENDSWITCH;
           }
         case 227: break;
-        case 131:
+        case 132:
           { return PHPTokenId.PHP_PRIVATE;
           }
         case 228: break;
@@ -2373,26 +2345,26 @@ public PHPTokenId nextToken() throws java.io.IOException {
           { return PHPTokenId.T_INLINE_HTML;
           }
         case 229: break;
-        case 152:
+        case 153:
           { return PHPTokenId.PHP_YIELD_FROM;
           }
         case 230: break;
-        case 93:
+        case 94:
           { return PHPTokenId.PHP_ENDIF;
           }
         case 231: break;
-        case 32:
+        case 33:
           { yypushback(1);
     popState();
         if (yylength() > 0)
             return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
           }
         case 232: break;
-        case 117:
+        case 118:
           { return PHPTokenId.PHP_STATIC;
           }
         case 233: break;
-        case 128:
+        case 129:
           { return PHPTokenId.PHP_DEFAULT;
           }
         case 234: break;
@@ -2400,25 +2372,25 @@ public PHPTokenId nextToken() throws java.io.IOException {
           { return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
           }
         case 235: break;
-        case 29:
+        case 30:
           { popState();
     return PHPTokenId.PHP_TOKEN;
           }
         case 236: break;
-        case 41:
+        case 42:
           { pushState(ST_PHP_LOOKING_FOR_PROPERTY);
     return PHPTokenId.PHP_OBJECT_OPERATOR;
           }
         case 237: break;
-        case 140:
+        case 141:
           { return PHPTokenId.PHP__LINE__;
           }
         case 238: break;
-        case 79:
+        case 80:
           { return PHPTokenId.PHP_EXIT;
           }
         case 239: break;
-        case 39:
+        case 40:
           { if (aspTagsAllowed) {
         //yybegin(ST_PHP_IN_SCRIPTING);
         pushState(ST_PHP_IN_SCRIPTING);
@@ -2430,16 +2402,16 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
           }
         case 240: break;
-        case 43:
+        case 44:
           { pushState(ST_PHP_COMMENT);
     return PHPTokenId.PHP_COMMENT_START;
           }
         case 241: break;
-        case 97:
+        case 98:
           { return PHPTokenId.PHP_BREAK;
           }
         case 242: break;
-        case 30:
+        case 31:
           { if(parenBalanceInConst == 0 && bracketBalanceInConst == 0) {
         isInConst = false;
     }
@@ -2447,25 +2419,25 @@ public PHPTokenId nextToken() throws java.io.IOException {
     popState();
           }
         case 243: break;
-        case 21:
+        case 22:
           { yypushback(1);
         yybegin(ST_PHP_HEREDOC);
           }
         case 244: break;
-        case 144:
+        case 145:
           { return PHPTokenId.PHP_INSTEADOF;
           }
         case 245: break;
-        case 24:
+        case 25:
           { /* <ST_PHP_NOWDOC>{NOWDOC_CHARS}|{NEWLINE} */
         // retrun PHPTokenId when the closing marker is found
           }
         case 246: break;
-        case 145:
+        case 146:
           { return PHPTokenId.PHP_PROTECTED;
           }
         case 247: break;
-        case 66:
+        case 67:
           { String text = yytext();
     if ((text.charAt(1)=='%' && aspTagsAllowed)
         || (text.charAt(1)=='?')) {
@@ -2479,57 +2451,57 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
           }
         case 248: break;
-        case 108:
+        case 109:
           { return PHPTokenId.PHP_PRINT;
           }
         case 249: break;
-        case 72:
+        case 73:
           { return PHPTokenId.PHP_VAR;
           }
         case 250: break;
-        case 159:
+        case 160:
           { pushState(ST_PHP_IN_SCRIPTING);
     return PHPTokenId.T_INLINE_HTML;
           }
         case 251: break;
-        case 102:
+        case 103:
           { return PHPTokenId.PHP_THROW;
           }
         case 252: break;
-        case 121:
+        case 122:
           { return PHPTokenId.PHP_PARENT;
           }
         case 253: break;
-        case 119:
+        case 120:
           { return PHPTokenId.PHP_SWITCH;
           }
         case 254: break;
-        case 78:
+        case 79:
           { yypushback(2); // go back to mark end of comment in the next token
         return PHPTokenId.PHPDOC_COMMENT;
           }
         case 255: break;
-        case 70:
+        case 71:
           { return PHPTokenId.PHP_TYPE_INT;
           }
         case 256: break;
-        case 110:
+        case 111:
           { return PHPTokenId.PHP_CASTING;
           }
         case 257: break;
-        case 46:
+        case 47:
           { return PHPTokenId.PHP_TEXTUAL_OPERATOR;
           }
         case 258: break;
-        case 37:
+        case 38:
           { popState();return PHPTokenId.WHITESPACE;
           }
         case 259: break;
-        case 69:
+        case 70:
           { return PHPTokenId.PHP_DIE;
           }
         case 260: break;
-        case 147:
+        case 148:
           { return PHPTokenId.PHP__CLASS__;
           }
         case 261: break;
@@ -2538,23 +2510,23 @@ public PHPTokenId nextToken() throws java.io.IOException {
     pushState(ST_PHP_HIGHLIGHTING_ERROR);
           }
         case 262: break;
-        case 107:
+        case 108:
           { return PHPTokenId.PHP_CLASS;
           }
         case 263: break;
-        case 125:
+        case 126:
           { return PHPTokenId.PHP_FINALLY;
           }
         case 264: break;
-        case 143:
+        case 144:
           { return PHPTokenId.PHP_INTERFACE;
           }
         case 265: break;
-        case 146:
+        case 147:
           { return PHPTokenId.PHP__TRAIT__;
           }
         case 266: break;
-        case 109:
+        case 110:
           { return PHPTokenId.PHP_UNSET;
           }
         case 267: break;
@@ -2562,53 +2534,65 @@ public PHPTokenId nextToken() throws java.io.IOException {
           { return PHPTokenId.PHP_CURLY_OPEN;
           }
         case 268: break;
-        case 27:
+        case 28:
           { yypushback(1);
     popState();
           }
         case 269: break;
-        case 122:
+        case 123:
           { return PHPTokenId.PHP_PUBLIC;
           }
         case 270: break;
-        case 154:
-          { return PHPTokenId.PHP_REQUIRE_ONCE;
+        case 21:
+          { int indexOfNewline = yytext().indexOf("\r");
+        if (indexOfNewline == -1) {
+            indexOfNewline = yytext().indexOf("\n");
+        }
+        if (indexOfNewline > 0) {
+            // if index equals 0, don't pushback (infinite loop)
+            yypushback(yylength() - indexOfNewline);
+        }
+        return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
           }
         case 271: break;
-        case 148:
-          { return PHPTokenId.PHP_ENDFOREACH;
+        case 155:
+          { return PHPTokenId.PHP_REQUIRE_ONCE;
           }
         case 272: break;
-        case 118:
-          { return PHPTokenId.PHP_TYPE_STRING;
+        case 149:
+          { return PHPTokenId.PHP_ENDFOREACH;
           }
         case 273: break;
-        case 81:
-          { return PHPTokenId.PHP_EVAL;
+        case 119:
+          { return PHPTokenId.PHP_TYPE_STRING;
           }
         case 274: break;
-        case 88:
-          { return PHPTokenId.PHP_GOTO;
+        case 82:
+          { return PHPTokenId.PHP_EVAL;
           }
         case 275: break;
-        case 104:
+        case 89:
+          { return PHPTokenId.PHP_GOTO;
+          }
+        case 276: break;
+        case 105:
           { isInConst = true;
     parenBalanceInConst = 0;
     bracketBalanceInConst = 0;
     pushState(ST_PHP_LOOKING_FOR_CONSTANT_NAME);
     return PHPTokenId.PHP_CONST;
           }
-        case 276: break;
+        case 277: break;
         case 20:
           { popState();
         return PHPTokenId.PHP_STRING;
           }
-        case 277: break;
-        case 135:
+        case 278: break;
+        case 136:
           { return PHPTokenId.PHP_ABSTRACT;
           }
-        case 278: break;
-        case 26:
+        case 279: break;
+        case 27:
           { heredoc=null; hereocLength=0;
     yybegin(ST_PHP_IN_SCRIPTING);
     int back = 0;
@@ -2619,13 +2603,13 @@ public PHPTokenId nextToken() throws java.io.IOException {
     yypushback(back);
     return PHPTokenId.PHP_NOWDOC_TAG_END;
           }
-        case 279: break;
+        case 280: break;
         case 9:
           { pushState(ST_PHP_DOUBLE_QUOTES);
     return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
           }
-        case 280: break;
-        case 59:
+        case 281: break;
+        case 60:
           { /* <ST_START_NOWDOC>{TABS_AND_SPACES}{LABEL}";"?[^\n\r]*[\r\n]? */
     // there is no [\r\n] if it is the last line
     // i.e. not [\r\n] but EOF, so check not [\r\n] but [\r\n]?
@@ -2642,96 +2626,132 @@ public PHPTokenId nextToken() throws java.io.IOException {
         yybegin(ST_PHP_NOWDOC);
     }
           }
-        case 281: break;
-        case 82:
+        case 282: break;
+        case 83:
           { return PHPTokenId.PHP_ECHO;
           }
-        case 282: break;
-        case 96:
+        case 283: break;
+        case 97:
           { return PHPTokenId.PHP_FINAL;
           }
-        case 283: break;
-        case 153:
+        case 284: break;
+        case 154:
           { return PHPTokenId.PHP__METHOD__;
           }
-        case 284: break;
+        case 285: break;
         case 10:
           { return PHPTokenId.PHP_NS_SEPARATOR;
           }
-        case 285: break;
-        case 111:
+        case 286: break;
+        case 112:
           { return PHPTokenId.PHP_YIELD;
           }
-        case 286: break;
-        case 134:
+        case 287: break;
+        case 135:
           { pushState(ST_PHP_LOOKING_FOR_FUNCTION_NAME);
     return PHPTokenId.PHP_FUNCTION;
           }
-        case 287: break;
-        case 132:
+        case 288: break;
+        case 133:
           { return PHPTokenId.PHP__DIR__;
           }
-        case 288: break;
+        case 289: break;
         case 5:
           { return  PHPTokenId.PHP_STRING;
           }
-        case 289: break;
-        case 137:
+        case 290: break;
+        case 138:
           { return PHPTokenId.PHP_CONTINUE;
           }
-        case 290: break;
-        case 151:
+        case 291: break;
+        case 58:
+          { /* {NEWLINE}{TABS_AND_SPACES}{LABEL}";"?[^\n\r]*[\n\r]? */
+        int trailingNewLineLength = 1;
+        if (isEndHeredoc()) {
+            String yytext = yytext();
+            int newlineLength = yytext.startsWith("\r\n") ? 2 : 1;
+            int back = yylength() - newlineLength;
+            yypushback(back);
+            yybegin(ST_PHP_END_HEREDOC);
+        } else {
+            // handle variable
+            char previousChar = ' ';
+            int indexOfVariable = -1;
+            for (int i = 0; i < yylength(); i++) {
+                char currentChar = yytext().charAt(i);
+                if (currentChar == '$' && previousChar == '{') {
+                    indexOfVariable = i - 1;
+                    break;
+                }
+                if (currentChar == '$' && previousChar != '\\') {
+                    indexOfVariable = i;
+                    break;
+                }
+                previousChar = currentChar;
+            }
+
+            if (indexOfVariable == -1) {
+                yypushback(trailingNewLineLength);
+            } else {
+                yypushback(yylength() - indexOfVariable);
+                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
+            }
+        }
+        return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
+          }
+        case 292: break;
+        case 152:
           { return PHPTokenId.PHP_IMPLEMENTS;
           }
-        case 291: break;
-        case 71:
+        case 293: break;
+        case 72:
           { return PHPTokenId.PHP_TRY;
           }
-        case 292: break;
-        case 99:
+        case 294: break;
+        case 100:
           { return PHPTokenId.PHP_ARRAY;
           }
-        case 293: break;
+        case 295: break;
         case 7:
           { return PHPTokenId.WHITESPACE;
           }
-        case 294: break;
-        case 115:
+        case 296: break;
+        case 116:
           { return PHPTokenId.PHP_RETURN;
           }
-        case 295: break;
-        case 33:
+        case 297: break;
+        case 34:
           { return PHPTokenId.PHP_TOKEN;
           }
-        case 296: break;
+        case 298: break;
         case 16:
           { return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
           }
-        case 297: break;
-        case 105:
+        case 299: break;
+        case 106:
           { return PHPTokenId.PHP_CATCH;
           }
-        case 298: break;
-        case 75:
+        case 300: break;
+        case 76:
           { String text = yytext();
         int lastIndexOfDollar = text.lastIndexOf('$');
         yypushback(text.length() - lastIndexOfDollar);
         return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
           }
-        case 299: break;
-        case 56:
+        case 301: break;
+        case 57:
           { return PHPTokenId.PHP_PAAMAYIM_NEKUDOTAYIM;
           }
-        case 300: break;
-        case 138:
+        case 302: break;
+        case 139:
           { return PHPTokenId.PHP_CALLABLE;
           }
-        case 301: break;
-        case 150:
+        case 303: break;
+        case 151:
           { return PHPTokenId.PHP_INSTANCEOF;
           }
-        case 302: break;
-        case 126:
+        case 304: break;
+        case 127:
           { int bprefix = (yytext().charAt(0) != '<') ? 1 : 0;
         int startString=3+bprefix;
         /* 3 is <<<, 2 is quotes, 1 is newline */
@@ -2746,46 +2766,46 @@ public PHPTokenId nextToken() throws java.io.IOException {
         yybegin(ST_PHP_START_NOWDOC);
         return PHPTokenId.PHP_NOWDOC_TAG_START;
           }
-        case 303: break;
-        case 89:
+        case 305: break;
+        case 90:
           { return PHPTokenId.PHP_TYPE_BOOL;
           }
-        case 304: break;
-        case 113:
+        case 306: break;
+        case 114:
           { return PHPTokenId.PHP_ENDFOR;
           }
-        case 305: break;
-        case 67:
+        case 307: break;
+        case 68:
           { return PHPTokenId.PHP_FOR;
           }
-        case 306: break;
-        case 124:
+        case 308: break;
+        case 125:
           { return PHPTokenId.PHP_FOREACH;
           }
-        case 307: break;
-        case 50:
+        case 309: break;
+        case 51:
           { pushState(ST_PHP_LOOKING_FOR_STATIC_PROPERTY);
     return PHPTokenId.PHP_PAAMAYIM_NEKUDOTAYIM;
           }
-        case 308: break;
-        case 28:
+        case 310: break;
+        case 29:
           { popState();
     return PHPTokenId.PHP_STRING;
           }
-        case 309: break;
-        case 80:
+        case 311: break;
+        case 81:
           { return PHPTokenId.PHP_ELSE;
           }
-        case 310: break;
-        case 87:
+        case 312: break;
+        case 88:
           { return PHPTokenId.PHP_SELF;
           }
-        case 311: break;
-        case 52:
+        case 313: break;
+        case 53:
           { yypushback(1);
     return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
           }
-        case 312: break;
+        case 314: break;
         case 14:
           { int lastState = stack.peek();
     if (lastState != ST_PHP_IN_SCRIPTING && lastState != YYINITIAL) {
@@ -2794,27 +2814,27 @@ public PHPTokenId nextToken() throws java.io.IOException {
     }
     return PHPTokenId.PHP_CURLY_CLOSE;
           }
-        case 313: break;
-        case 48:
+        case 315: break;
+        case 49:
           { return PHPTokenId.PHP_DO;
           }
-        case 314: break;
-        case 90:
+        case 316: break;
+        case 91:
           { return PHPTokenId.PHP_TYPE_VOID;
           }
-        case 315: break;
-        case 133:
+        case 317: break;
+        case 134:
           { return PHPTokenId.PHP_ENDWHILE;
           }
-        case 316: break;
-        case 114:
+        case 318: break;
+        case 115:
           { return PHPTokenId.PHP_ELSEIF;
           }
-        case 317: break;
-        case 85:
+        case 319: break;
+        case 86:
           { return PHPTokenId.PHP_TRUE;
           }
-        case 318: break;
+        case 320: break;
         default:
           if (zzInput == YYEOF)
             //zzAtEOF = true;
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Scanner.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Scanner.java
index 52cc1cacba..a7f6ff7039 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Scanner.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Scanner.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 18/09/17 17:24 */
+/* The following code was generated by JFlex 1.4.3 on 18/10/28 6:34 */
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -33,7 +33,7 @@
 /**
  * This class is a scanner generated by
  * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 18/09/17 17:24 from the specification file
+ * on 18/10/28 6:34 from the specification file
  * <tt>/home/junichi11/NetBeansProjects/incubator-netbeans/php/php.editor/tools/ASTPHP5Scanner.flex</tt>
  */
 public class ASTPHP5Scanner implements Scanner {
@@ -2244,196 +2244,243 @@ else if (zzAtEOF) {
 	return createSymbol(ASTPHP5Symbols.T_HALT_COMPILER);
           }
         case 260: break;
+        case 102:
+          { /* {NEWLINE}{TABS_AND_SPACES}{LABEL}";"?[^\n\r]*[\n\r]? */
+        int trailingNewLineLength = 1;
+        int labelLength = yylength() - trailingNewLineLength;
+        int back = trailingNewLineLength;
+
+        if (yytext().charAt(labelLength-1) == ';') {
+           labelLength--;
+           back++;
+        }
+
+        if (isEndHereOrNowdoc(heredoc)) {
+            int indexOfHeredocId = yytext().indexOf(heredoc);
+            back += labelLength - indexOfHeredocId;
+            yypushback(back);
+            yybegin(ST_END_HEREDOC);
+        } else {
+            // handle variable
+            char previousChar = ' ';
+            int indexOfVariable = -1;
+            for (int i = 0; i < yylength(); i++) {
+                char currentChar = yytext().charAt(i);
+                if (currentChar == '$' && previousChar == '{') {
+                    indexOfVariable = i - 1;
+                    break;
+                }
+                if (currentChar == '$' && previousChar != '\\') {
+                    indexOfVariable = i;
+                    break;
+                }
+                previousChar = currentChar;
+            }
+
+            if (indexOfVariable == -1) {
+                yypushback(trailingNewLineLength);
+            } else {
+                yypushback(yylength() - indexOfVariable);
+                updateHeredocBodyInfo();
+                return createFullHeredocBodySymbol();
+            }
+        }
+        updateHeredocBodyInfo();
+        if (yystate() == ST_END_HEREDOC) {
+            return createFullHeredocBodySymbol();
+        }
+          }
+        case 261: break;
         case 61:
           { yybegin(ST_IN_SCRIPTING);
     return createSymbol(ASTPHP5Symbols.T_ECHO);
           }
-        case 261: break;
+        case 262: break;
         case 163:
           { return createFullSymbol(ASTPHP5Symbols.T_SWITCH);
           }
-        case 262: break;
+        case 263: break;
         case 56:
           { popState();
 	return createSymbol(ASTPHP5Symbols.T_CLOSE_RECT);
           }
-        case 263: break;
+        case 264: break;
         case 32:
           { return createSymbol(ASTPHP5Symbols.T_TILDA);
           }
-        case 264: break;
+        case 265: break;
         case 73:
           { return createFullSymbol(ASTPHP5Symbols.T_IF);
           }
-        case 265: break;
+        case 266: break;
         case 175:
           { return createFullSymbol(ASTPHP5Symbols.T_REQUIRE);
           }
-        case 266: break;
+        case 267: break;
         case 17:
           { return createSymbol(ASTPHP5Symbols.T_NEKUDOTAIM);
           }
-        case 267: break;
+        case 268: break;
         case 25:
           { return createSymbol(ASTPHP5Symbols.T_REFERENCE);
           }
-        case 268: break;
+        case 269: break;
         case 88:
           { handleCommentStart();
     yybegin(ST_COMMENT);
           }
-        case 269: break;
+        case 270: break;
         case 193:
           { return createFullSymbol(ASTPHP5Symbols.T_NAMESPACE);
           }
-        case 270: break;
+        case 271: break;
         case 200:
           { return createFullSymbol(ASTPHP5Symbols.T_IMPLEMENTS);
           }
-        case 271: break;
+        case 272: break;
         case 152:
           { return createFullSymbol(ASTPHP5Symbols.T_YIELD);
           }
-        case 272: break;
+        case 273: break;
         case 15:
           { return createSymbol(ASTPHP5Symbols.T_MINUS);
           }
-        case 273: break;
+        case 274: break;
         case 44:
           { /* <ST_NOWDOC>{NOWDOC_CHARS}|{NEWLINE} */
         updateNowdocBodyInfo();
           }
-        case 274: break;
+        case 275: break;
         case 196:
           { return createFullSymbol(ASTPHP5Symbols.T_CLASS_C);
           }
-        case 275: break;
+        case 276: break;
         case 109:
           { handlePHPDocEnd();
      yybegin(ST_IN_SCRIPTING);
           }
-        case 276: break;
+        case 277: break;
         case 207:
           { return createFullSymbol(ASTPHP5Symbols.T_NS_C);
           }
-        case 277: break;
+        case 278: break;
         case 155:
           { return createSymbol(ASTPHP5Symbols.T_INT_CAST);
           }
-        case 278: break;
+        case 279: break;
         case 160:
           { return createFullSymbol(ASTPHP5Symbols.T_ELSEIF);
           }
-        case 279: break;
+        case 280: break;
         case 97:
           { return createSymbol(ASTPHP5Symbols.T_COALESCE);
           }
-        case 280: break;
+        case 281: break;
         case 197:
           { return createFullSymbol(ASTPHP5Symbols.T_ENDDECLARE);
           }
-        case 281: break;
+        case 282: break;
         case 77:
           { return createSymbol(ASTPHP5Symbols.T_DEC);
           }
-        case 282: break;
+        case 283: break;
         case 98:
           { yypushback(1);
     /*<ST_DOUBLE_QUOTES>{DOUBLE_QUOTES_CHARS}*("{""{"+|"$""$"+|(("{"+|"$"+)[\"]))*/
     return createFullSymbol(ASTPHP5Symbols.T_ENCAPSED_AND_WHITESPACE);
           }
-        case 283: break;
+        case 284: break;
         case 182:
           { return createFullSymbol(ASTPHP5Symbols.T_ABSTRACT);
           }
-        case 284: break;
+        case 285: break;
         case 133:
           { return createFullSymbol(ASTPHP5Symbols.T_ELSE);
           }
-        case 285: break;
+        case 286: break;
         case 192:
           { return createFullSymbol(ASTPHP5Symbols.T_INSTEADOF);
           }
-        case 286: break;
+        case 287: break;
         case 78:
           { pushState(ST_LOOKING_FOR_PROPERTY);
     return createSymbol(ASTPHP5Symbols.T_OBJECT_OPERATOR);
           }
-        case 287: break;
+        case 288: break;
         case 13:
           { return createSymbol(ASTPHP5Symbols.T_SEMICOLON);
           }
-        case 288: break;
+        case 289: break;
         case 2:
           { // do nothing
           }
-        case 289: break;
+        case 290: break;
         case 50:
           { popState();
     pushState(ST_IN_SCRIPTING);
     return createFullSymbol(ASTPHP5Symbols.T_STRING_VARNAME);
           }
-        case 290: break;
+        case 291: break;
         case 16:
           { return createSymbol(ASTPHP5Symbols.T_LGREATER);
           }
-        case 291: break;
+        case 292: break;
         case 136:
           { return createFullSymbol(ASTPHP5Symbols.T_LIST);
           }
-        case 292: break;
+        case 293: break;
         case 108:
           { handleMultilineCommentEnd();
     yybegin(ST_IN_SCRIPTING);
           }
-        case 293: break;
+        case 294: break;
         case 159:
           { return createFullSymbol(ASTPHP5Symbols.T_ENDFOR);
           }
-        case 294: break;
+        case 295: break;
         case 3:
           { return createFullSymbol(ASTPHP5Symbols.T_LNUMBER);
           }
-        case 295: break;
+        case 296: break;
         case 101:
           { yypushback(1);
         /*<ST_BACKQUOTE>{BACKQUOTE_CHARS}*("{""{"+|"$""$"+|(("{"+|"$"+)[`]))*/
 	return createFullSymbol(ASTPHP5Symbols.T_ENCAPSED_AND_WHITESPACE);
           }
-        case 296: break;
+        case 297: break;
         case 41:
           { /* <ST_HEREDOC> "$" | "{" */
         updateHeredocBodyInfo();
           }
-        case 297: break;
+        case 298: break;
         case 138:
           { handleCommentStart();
           }
-        case 298: break;
+        case 299: break;
         case 141:
           { return createFullSymbol(ASTPHP5Symbols.T_ARRAY);
           }
-        case 299: break;
+        case 300: break;
         case 132:
           { return createFullSymbol(ASTPHP5Symbols.T_ECHO);
           }
-        case 300: break;
+        case 301: break;
         case 51:
           { return createFullSymbol(ASTPHP5Symbols.T_NUM_STRING);
           }
-        case 301: break;
+        case 302: break;
         case 91:
           { return createSymbol(ASTPHP5Symbols.T_AND_EQUAL);
           }
-        case 302: break;
+        case 303: break;
         case 55:
           { bracket++; return createSymbol(ASTPHP5Symbols.T_CURLY_OPEN);
           }
-        case 303: break;
+        case 304: break;
         case 145:
           { return createFullSymbol(ASTPHP5Symbols.T_THROW);
           }
-        case 304: break;
+        case 305: break;
         case 129:
           { /* <ST_HEREDOC> {HEREDOC_CHARS}"$"{LABEL}"["? */
         String text = yytext();
@@ -2442,15 +2489,15 @@ else if (zzAtEOF) {
         updateHeredocBodyInfo();
         return createFullHeredocBodySymbol();
           }
-        case 305: break;
+        case 306: break;
         case 153:
           { return createFullSymbol(ASTPHP5Symbols.T_WHILE);
           }
-        case 306: break;
+        case 307: break;
         case 190:
           { return createFullSymbol(ASTPHP5Symbols.T_ENDSWITCH);
           }
-        case 307: break;
+        case 308: break;
         case 62:
           { if (asp_tags) {
         yybegin(ST_IN_SCRIPTING);
@@ -2460,51 +2507,10 @@ else if (zzAtEOF) {
         return createSymbol(ASTPHP5Symbols.T_INLINE_HTML);
     }
           }
-        case 308: break;
+        case 309: break;
         case 177:
           { return createSymbol(ASTPHP5Symbols.T_ARRAY_CAST);
           }
-        case 309: break;
-        case 102:
-          { /* {NEWLINE}{TABS_AND_SPACES}{LABEL}";"?[^\n\r]*[\n\r]? */
-        int trailingNewLineLength = 1;
-        int labelLength = yylength() - trailingNewLineLength;
-        int back = trailingNewLineLength;
-
-        if (yytext().charAt(labelLength-1) == ';') {
-           labelLength--;
-           back++;
-        }
-
-        if (isEndHereOrNowdoc(heredoc)) {
-            int indexOfHeredocId = yytext().indexOf(heredoc);
-            back += labelLength - indexOfHeredocId;
-            yypushback(back);
-            yybegin(ST_END_HEREDOC);
-        } else {
-            int indexOfVariable1 = yytext().indexOf("$");
-            int indexOfVariable2 = yytext().indexOf("{$");
-            if (indexOfVariable1 > 0 && indexOfVariable2 == -1) {
-                yypushback(yylength() - indexOfVariable1);
-                updateHeredocBodyInfo();
-                return createFullHeredocBodySymbol();
-            } else if (indexOfVariable2 > 0 && indexOfVariable1 == -1) {
-                yypushback(yylength() - indexOfVariable2);
-                updateHeredocBodyInfo();
-                return createFullHeredocBodySymbol();
-            } else if (indexOfVariable1 > 0 && indexOfVariable2 > 0) {
-                yypushback(yylength() - Math.min(indexOfVariable1, indexOfVariable2));
-                updateHeredocBodyInfo();
-                return createFullHeredocBodySymbol();
-            } else {
-                yypushback(trailingNewLineLength);
-            }
-        }
-        updateHeredocBodyInfo();
-        if (yystate() == ST_END_HEREDOC) {
-            return createFullHeredocBodySymbol();
-        }
-          }
         case 310: break;
         case 100:
           { pushState(ST_IN_SCRIPTING);
@@ -2639,34 +2645,47 @@ else if (zzAtEOF) {
           { return createSymbol(ASTPHP5Symbols.T_BOOLEAN_AND);
           }
         case 332: break;
+        case 40:
+          { /* <ST_HEREDOC> {HEREDOC_CHARS} */
+        int indexOfNewline = yytext().indexOf("\r");
+        if (indexOfNewline == -1) {
+            indexOfNewline = yytext().indexOf("\n");
+        }
+        if (indexOfNewline > 0) {
+            // if index equals 0, don't pushback (infinite loop)
+            yypushback(yylength() - indexOfNewline);
+        }
+        updateHeredocBodyInfo();
+          }
+        case 333: break;
         case 5:
           { return createFullSymbol(ASTPHP5Symbols.T_STRING);
           }
-        case 333: break;
+        case 334: break;
         case 170:
           { return createFullSymbol(ASTPHP5Symbols.T_INCLUDE);
           }
-        case 334: break;
+        case 335: break;
         case 4:
           { return createSymbol(ASTPHP5Symbols.T_NEKUDA);
           }
-        case 335: break;
+        case 336: break;
         case 139:
           { return createFullSymbol(ASTPHP5Symbols.T_ENDIF);
           }
-        case 336: break;
+        case 337: break;
         case 120:
           { return createFullSymbol(ASTPHP5Symbols.T_NEW);
           }
-        case 337: break;
+        case 338: break;
         case 57:
           { bracket--; return createSymbol(ASTPHP5Symbols.T_CURLY_CLOSE);
           }
-        case 338: break;
+        case 339: break;
         case 199:
           { return createFullSymbol(ASTPHP5Symbols.T_INSTANCEOF);
           }
-        case 339: break;
+        case 340: break;
         case 180:
           { int bprefix = (yytext().charAt(0) != '<') ? 1 : 0;
         int startString=3+bprefix;
@@ -2682,13 +2701,13 @@ else if (zzAtEOF) {
         yybegin(ST_START_NOWDOC);
         return createSymbol(ASTPHP5Symbols.T_START_NOWDOC);
           }
-        case 340: break;
+        case 341: break;
         case 49:
           { yypushback(yylength());
     popState();
     pushState(ST_IN_SCRIPTING);
           }
-        case 341: break;
+        case 342: break;
         case 158:
           { isEndedPhp = false;
     whitespaceEndPosition = getTokenStartPosition() + yylength();
@@ -2696,47 +2715,47 @@ else if (zzAtEOF) {
     //return T_OPEN_TAG;
     //return createSymbol(ASTPHP5Symbols.T_OPEN_TAG);
           }
-        case 342: break;
+        case 343: break;
         case 67:
           { return createSymbol(ASTPHP5Symbols.T_PLUS_EQUAL);
           }
-        case 343: break;
+        case 344: break;
         case 8:
           { whitespaceEndPosition = getTokenStartPosition() + yylength();
           }
-        case 344: break;
+        case 345: break;
         case 176:
           { return createFullSymbol(ASTPHP5Symbols.T_PRIVATE);
           }
-        case 345: break;
+        case 346: break;
         case 204:
           { return createFullSymbol(ASTPHP5Symbols.T_REQUIRE_ONCE);
           }
-        case 346: break;
+        case 347: break;
         case 174:
           { return createFullSymbol(ASTPHP5Symbols.T_FOREACH);
           }
-        case 347: break;
+        case 348: break;
         case 151:
           { return createFullSymbol(ASTPHP5Symbols.T_CLONE);
           }
-        case 348: break;
+        case 349: break;
         case 143:
           { return createFullSymbol(ASTPHP5Symbols.T_ISSET);
           }
-        case 349: break;
+        case 350: break;
         case 18:
           { return createSymbol(ASTPHP5Symbols.T_OPEN_PARENTHESE);
           }
-        case 350: break;
+        case 351: break;
         case 166:
           { return createFullSymbol(ASTPHP5Symbols.T_PUBLIC);
           }
-        case 351: break;
+        case 352: break;
         case 121:
           { return createSymbol(ASTPHP5Symbols.T_SR_EQUAL);
           }
-        case 352: break;
+        case 353: break;
         case 63:
           { if (short_tags_allowed || yylength()>2) { /* yyleng>2 means it's not <? but <script> */
         yybegin(ST_IN_SCRIPTING);
@@ -2746,15 +2765,10 @@ else if (zzAtEOF) {
         return createSymbol(ASTPHP5Symbols.T_INLINE_HTML);
     }
           }
-        case 353: break;
+        case 354: break;
         case 140:
           { return createFullSymbol(ASTPHP5Symbols.T_EMPTY);
           }
-        case 354: break;
-        case 40:
-          { /* <ST_HEREDOC> {HEREDOC_CHARS} */
-        updateHeredocBodyInfo();
-          }
         case 355: break;
         case 82:
           { return createSymbol(ASTPHP5Symbols.T_IS_NOT_EQUAL);
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_01.pass
new file mode 100644
index 0000000000..5b85bf8f15
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_01.pass
@@ -0,0 +1,18 @@
+token #0 PHP_OPENTAG <?php
+token #1 WHITESPACE \n
+token #2 PHP_COMMENT_START /*
+token #3 PHP_COMMENT \n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements.  See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership.  The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * "License"); you may not use this file except in compliance\n * with the License.  You may obtain a copy of the License at\n *\n *   http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n 
+token #4 PHP_COMMENT_END */
+token #5 WHITESPACE \n\n
+token #6 PHP_VARIABLE $code
+token #7 WHITESPACE  
+token #8 PHP_OPERATOR =
+token #9 WHITESPACE  
+token #10 PHP_HEREDOC_TAG_START <<<EOF\n
+token #11 PHP_CONSTANT_ENCAPSED_STRING \n    if(!isset(\$test1[\$test2])) {
+token #12 PHP_CONSTANT_ENCAPSED_STRING \n        break;
+token #13 PHP_CONSTANT_ENCAPSED_STRING \n    }
+token #14 PHP_CONSTANT_ENCAPSED_STRING \n
+token #15 PHP_HEREDOC_TAG_END EOF
+token #16 PHP_SEMICOLON ;
+token #17 WHITESPACE \n
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_02.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_02.pass
new file mode 100644
index 0000000000..4f5ec7a4ed
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_02.pass
@@ -0,0 +1,16 @@
+token #0 PHP_OPENTAG <?php
+token #1 WHITESPACE \n
+token #2 PHP_COMMENT_START /*
+token #3 PHP_COMMENT \n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements.  See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership.  The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * "License"); you may not use this file except in compliance\n * with the License.  You may obtain a copy of the License at\n *\n *   http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n 
+token #4 PHP_COMMENT_END */
+token #5 WHITESPACE \n\n
+token #6 PHP_VARIABLE $code
+token #7 WHITESPACE  
+token #8 PHP_OPERATOR =
+token #9 WHITESPACE  
+token #10 PHP_HEREDOC_TAG_START <<<EOF\n
+token #11 PHP_CONSTANT_ENCAPSED_STRING \
+token #12 PHP_CONSTANT_ENCAPSED_STRING \n
+token #13 PHP_HEREDOC_TAG_END EOF
+token #14 PHP_SEMICOLON ;
+token #15 WHITESPACE \n
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_03.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_03.pass
new file mode 100644
index 0000000000..55407cde06
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_03.pass
@@ -0,0 +1,21 @@
+token #0 PHP_OPENTAG <?php
+token #1 WHITESPACE \n
+token #2 PHP_COMMENT_START /*
+token #3 PHP_COMMENT \n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements.  See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership.  The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * "License"); you may not use this file except in compliance\n * with the License.  You may obtain a copy of the License at\n *\n *   http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n 
+token #4 PHP_COMMENT_END */
+token #5 WHITESPACE \n\n
+token #6 PHP_VARIABLE $code
+token #7 WHITESPACE  
+token #8 PHP_OPERATOR =
+token #9 WHITESPACE  
+token #10 PHP_HEREDOC_TAG_START <<<EOF\n
+token #11 PHP_ENCAPSED_AND_WHITESPACE     \$test1
+token #12 PHP_VARIABLE $test
+token #13 PHP_TOKEN [
+token #14 PHP_NUMBER 0
+token #15 PHP_TOKEN ]
+token #16 PHP_CONSTANT_ENCAPSED_STRING \
+token #17 PHP_CONSTANT_ENCAPSED_STRING \n
+token #18 PHP_HEREDOC_TAG_END EOF
+token #19 PHP_SEMICOLON ;
+token #20 WHITESPACE \n
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_04.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_04.pass
new file mode 100644
index 0000000000..2411285b33
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/lexer/PHPLexerTest/lexer/netbeans1563_04.pass
@@ -0,0 +1,23 @@
+token #0 PHP_OPENTAG <?php
+token #1 WHITESPACE \n
+token #2 PHP_COMMENT_START /*
+token #3 PHP_COMMENT \n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements.  See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership.  The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * "License"); you may not use this file except in compliance\n * with the License.  You may obtain a copy of the License at\n *\n *   http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n 
+token #4 PHP_COMMENT_END */
+token #5 WHITESPACE \n\n
+token #6 PHP_VARIABLE $code
+token #7 WHITESPACE  
+token #8 PHP_OPERATOR =
+token #9 WHITESPACE  
+token #10 PHP_HEREDOC_TAG_START <<<EOF\n
+token #11 PHP_ENCAPSED_AND_WHITESPACE \n    if(!isset(\$test1[\$test2])) {// 
+token #12 PHP_VARIABLE $comment
+token #13 PHP_ENCAPSED_AND_WHITESPACE \$comment
+token #14 PHP_CURLY_OPEN {
+token #15 PHP_VARIABLE $comment
+token #16 PHP_CURLY_CLOSE }
+token #17 PHP_CONSTANT_ENCAPSED_STRING \n        break;
+token #18 PHP_CONSTANT_ENCAPSED_STRING \n    }
+token #19 PHP_CONSTANT_ENCAPSED_STRING \n
+token #20 PHP_HEREDOC_TAG_END EOF
+token #21 PHP_SEMICOLON ;
+token #22 WHITESPACE \n
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_01.pass
new file mode 100644
index 0000000000..9b134c8c14
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_01.pass
@@ -0,0 +1,45 @@
+<testresult testFile='netbeans1563_01.php'>
+    <scanner>
+        <token id='T_VARIABLE' start='815' end='820'>
+            <text>$code</text>
+        </token>
+        <token id='T_EQUAL' start='821' end='822'>
+            <text>=</text>
+        </token>
+        <token id='T_START_HEREDOC' start='823' end='830'>
+            <text>&lt;&lt;&lt;EOF\n</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='830' end='887'>
+            <text>\n    if(!isset(\$test1[\$test2])) {\n        break;\n    }\n</text>
+        </token>
+        <token id='T_END_HEREDOC' start='887' end='890'>
+            <text>EOF</text>
+        </token>
+        <token id='T_SEMICOLON' start='890' end='891'>
+            <text>;</text>
+        </token>
+        <token id='EOF' start='892' end='892'>
+            <text></text>
+        </token>
+    </scanner>
+    <Program start='0' end='892'>
+        <Comments>
+            <Comment start='6' end='813' commentType='multiLine'/>
+            <Comment start='6' end='813' commentType='multiLine'/>
+        </Comments>
+        <Statements>
+            <ExpressionStatement start='815' end='891'>
+                <Assignment start='815' end='890' operator='EQUAL'>
+                    <Variable start='815' end='820' isDollared='true'>
+                        <Identifier start='816' end='820' name='code'/>
+                    </Variable>
+                    <Quote start='823' end='890' type='HEREDOC'>
+                        <Expressions>
+                            <Scalar start='830' end='887' type='STRING' value='\n    if(!isset(\$test1[\$test2])) {\n        break;\n    }\n'/>
+                        </Expressions>
+                    </Quote>
+                </Assignment>
+            </ExpressionStatement>
+        </Statements>
+    </Program>
+</testresult>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_02.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_02.pass
new file mode 100644
index 0000000000..f7ac6cc275
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_02.pass
@@ -0,0 +1,45 @@
+<testresult testFile='netbeans1563_02.php'>
+    <scanner>
+        <token id='T_VARIABLE' start='815' end='820'>
+            <text>$code</text>
+        </token>
+        <token id='T_EQUAL' start='821' end='822'>
+            <text>=</text>
+        </token>
+        <token id='T_START_HEREDOC' start='823' end='830'>
+            <text>&lt;&lt;&lt;EOF\n</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='830' end='836'>
+            <text>    \\n</text>
+        </token>
+        <token id='T_END_HEREDOC' start='836' end='839'>
+            <text>EOF</text>
+        </token>
+        <token id='T_SEMICOLON' start='839' end='840'>
+            <text>;</text>
+        </token>
+        <token id='EOF' start='841' end='841'>
+            <text></text>
+        </token>
+    </scanner>
+    <Program start='0' end='841'>
+        <Comments>
+            <Comment start='6' end='813' commentType='multiLine'/>
+            <Comment start='6' end='813' commentType='multiLine'/>
+        </Comments>
+        <Statements>
+            <ExpressionStatement start='815' end='840'>
+                <Assignment start='815' end='839' operator='EQUAL'>
+                    <Variable start='815' end='820' isDollared='true'>
+                        <Identifier start='816' end='820' name='code'/>
+                    </Variable>
+                    <Quote start='823' end='839' type='HEREDOC'>
+                        <Expressions>
+                            <Scalar start='830' end='836' type='STRING' value='    \\n'/>
+                        </Expressions>
+                    </Quote>
+                </Assignment>
+            </ExpressionStatement>
+        </Statements>
+    </Program>
+</testresult>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass
new file mode 100644
index 0000000000..be326e27a8
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass
@@ -0,0 +1,73 @@
+<testresult testFile='netbeans1563_03.php'>
+    <scanner>
+        <token id='T_VARIABLE' start='815' end='820'>
+            <text>$code</text>
+        </token>
+        <token id='T_EQUAL' start='821' end='822'>
+            <text>=</text>
+        </token>
+        <token id='T_START_HEREDOC' start='823' end='830'>
+            <text>&lt;&lt;&lt;EOF\n</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='830' end='841'>
+            <text>    \$test1</text>
+        </token>
+        <token id='T_VARIABLE' start='841' end='846'>
+            <text>$test</text>
+        </token>
+        <token id='T_OPEN_RECT' start='846' end='847'>
+            <text>[</text>
+        </token>
+        <token id='T_NUM_STRING' start='847' end='848'>
+            <text>0</text>
+        </token>
+        <token id='T_CLOSE_RECT' start='848' end='849'>
+            <text>]</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='849' end='851'>
+            <text>\\n</text>
+        </token>
+        <token id='T_END_HEREDOC' start='851' end='854'>
+            <text>EOF</text>
+        </token>
+        <token id='T_SEMICOLON' start='854' end='855'>
+            <text>;</text>
+        </token>
+        <token id='EOF' start='856' end='856'>
+            <text></text>
+        </token>
+    </scanner>
+    <Program start='0' end='856'>
+        <Comments>
+            <Comment start='6' end='813' commentType='multiLine'/>
+            <Comment start='6' end='813' commentType='multiLine'/>
+        </Comments>
+        <Statements>
+            <ExpressionStatement start='815' end='855'>
+                <Assignment start='815' end='854' operator='EQUAL'>
+                    <Variable start='815' end='820' isDollared='true'>
+                        <Identifier start='816' end='820' name='code'/>
+                    </Variable>
+                    <Quote start='823' end='854' type='HEREDOC'>
+                        <Expressions>
+                            <Scalar start='830' end='841' type='STRING' value='    \$test1'/>
+                            <ArrayAccess start='841' end='849' type='VARIABLE_ARRAY' isDollared='false'>
+                                <ArrayDimension start='846' end='849'>
+                                    <Index>
+                                        <Scalar start='847' end='848' type='REAL' value='0'/>
+                                    </Index>
+                                </ArrayDimension>
+                                <Name>
+                                    <Variable start='841' end='846' isDollared='true'>
+                                        <Identifier start='842' end='846' name='test'/>
+                                    </Variable>
+                                </Name>
+                            </ArrayAccess>
+                            <Scalar start='849' end='851' type='STRING' value='\\n'/>
+                        </Expressions>
+                    </Quote>
+                </Assignment>
+            </ExpressionStatement>
+        </Statements>
+    </Program>
+</testresult>
diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_04.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_04.pass
new file mode 100644
index 0000000000..4f6bf21cc8
--- /dev/null
+++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_04.pass
@@ -0,0 +1,73 @@
+<testresult testFile='netbeans1563_04.php'>
+    <scanner>
+        <token id='T_VARIABLE' start='815' end='820'>
+            <text>$code</text>
+        </token>
+        <token id='T_EQUAL' start='821' end='822'>
+            <text>=</text>
+        </token>
+        <token id='T_START_HEREDOC' start='823' end='830'>
+            <text>&lt;&lt;&lt;EOF\n</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='830' end='868'>
+            <text>\n    if(!isset(\$test1[\$test2])) {// </text>
+        </token>
+        <token id='T_VARIABLE' start='868' end='876'>
+            <text>$comment</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='876' end='885'>
+            <text>\$comment</text>
+        </token>
+        <token id='T_CURLY_OPEN_WITH_DOLAR' start='885' end='886'>
+            <text>{</text>
+        </token>
+        <token id='T_VARIABLE' start='886' end='894'>
+            <text>$comment</text>
+        </token>
+        <token id='T_CURLY_CLOSE' start='894' end='895'>
+            <text>}</text>
+        </token>
+        <token id='T_ENCAPSED_AND_WHITESPACE' start='895' end='917'>
+            <text>\n        break;\n    }\n</text>
+        </token>
+        <token id='T_END_HEREDOC' start='917' end='920'>
+            <text>EOF</text>
+        </token>
+        <token id='T_SEMICOLON' start='920' end='921'>
+            <text>;</text>
+        </token>
+        <token id='EOF' start='922' end='922'>
+            <text></text>
+        </token>
+    </scanner>
+    <Program start='0' end='922'>
+        <Comments>
+            <Comment start='6' end='813' commentType='multiLine'/>
+            <Comment start='6' end='813' commentType='multiLine'/>
+        </Comments>
+        <Statements>
+            <ExpressionStatement start='815' end='921'>
+                <Assignment start='815' end='920' operator='EQUAL'>
+                    <Variable start='815' end='820' isDollared='true'>
+                        <Identifier start='816' end='820' name='code'/>
+                    </Variable>
+                    <Quote start='823' end='920' type='HEREDOC'>
+                        <Expressions>
+                            <Scalar start='830' end='868' type='STRING' value='\n    if(!isset(\$test1[\$test2])) {// '/>
+                            <Variable start='868' end='876' isDollared='true'>
+                                <Identifier start='869' end='876' name='comment'/>
+                            </Variable>
+                            <Scalar start='876' end='885' type='STRING' value='\$comment'/>
+                            <ReflectionVariable start='885' end='895'>
+                                <Variable start='886' end='894' isDollared='true'>
+                                    <Identifier start='887' end='894' name='comment'/>
+                                </Variable>
+                            </ReflectionVariable>
+                            <Scalar start='895' end='917' type='STRING' value='\n        break;\n    }\n'/>
+                        </Expressions>
+                    </Quote>
+                </Assignment>
+            </ExpressionStatement>
+        </Statements>
+    </Program>
+</testresult>
diff --git a/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_01.php b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_01.php
new file mode 100644
index 0000000000..f412ab1777
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_01.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+
+    if(!isset(\$test1[\$test2])) {
+        break;
+    }
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_02.php b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_02.php
new file mode 100644
index 0000000000..24cccfbaf4
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_02.php
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+\
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_03.php b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_03.php
new file mode 100644
index 0000000000..3b184d215b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_03.php
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+    \$test1$test[0]\
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_04.php b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_04.php
new file mode 100644
index 0000000000..2cd3b05c32
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/lexer/netbeans1563_04.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+
+    if(!isset(\$test1[\$test2])) {// $comment\$comment{$comment}
+        break;
+    }
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_01.php b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_01.php
new file mode 100644
index 0000000000..f412ab1777
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_01.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+
+    if(!isset(\$test1[\$test2])) {
+        break;
+    }
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_01.php.errors b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_01.php.errors
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_01.php.errors
@@ -0,0 +1 @@
+
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_02.php b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_02.php
new file mode 100644
index 0000000000..53eb86e656
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_02.php
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+    \
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_02.php.errors b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_02.php.errors
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_02.php.errors
@@ -0,0 +1 @@
+
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_03.php b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_03.php
new file mode 100644
index 0000000000..3b184d215b
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_03.php
@@ -0,0 +1,23 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+    \$test1$test[0]\
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_03.php.errors b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_03.php.errors
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_03.php.errors
@@ -0,0 +1 @@
+
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_04.php b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_04.php
new file mode 100644
index 0000000000..2cd3b05c32
--- /dev/null
+++ b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_04.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+$code = <<<EOF
+
+    if(!isset(\$test1[\$test2])) {// $comment\$comment{$comment}
+        break;
+    }
+EOF;
diff --git a/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_04.php.errors b/php/php.editor/test/unit/data/testfiles/parser/netbeans1563_04.php.errors
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/lexer/PHPLexerTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/lexer/PHPLexerTest.java
index 2ab9fe196c..6a32b53e51 100644
--- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/lexer/PHPLexerTest.java
+++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/lexer/PHPLexerTest.java
@@ -294,6 +294,23 @@ public void testHereDoc_04() throws Exception {
         performTest("lexer/heredoc_04");
     }
 
+    // HEREDOC
+    public void testNetBeans1563_01() throws Exception {
+        performTest("lexer/netbeans1563_01");
+    }
+
+    public void testNetBeans1563_02() throws Exception {
+        performTest("lexer/netbeans1563_02");
+    }
+
+    public void testNetBeans1563_03() throws Exception {
+        performTest("lexer/netbeans1563_03");
+    }
+
+    public void testNetBeans1563_04() throws Exception {
+        performTest("lexer/netbeans1563_04");
+    }
+
     public void testIssue222092_01() throws Exception {
         performTest("lexer/issue222092_01");
     }
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest.java
index 8c5cf7888b..7aea8f0ce1 100644
--- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest.java
+++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest.java
@@ -249,6 +249,23 @@ public void testHereDoc_17() throws Exception {
         performTest("parser/heredoc_015");
     }
 
+    // HEREDOC
+    public void testNetBeans1563_01() throws Exception {
+        performTest("parser/netbeans1563_01");
+    }
+
+    public void testNetBeans1563_02() throws Exception {
+        performTest("parser/netbeans1563_02");
+    }
+
+    public void testNetBeans1563_03() throws Exception {
+        performTest("parser/netbeans1563_03");
+    }
+
+    public void testNetBeans1563_04() throws Exception {
+        performTest("parser/netbeans1563_04");
+    }
+
     public void testVarCommentSimple01() throws Exception {
         performTest("parser/simple01");
     }
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PhpParserErrorTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PhpParserErrorTest.java
index e984c35507..cddff499bf 100644
--- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PhpParserErrorTest.java
+++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/parser/PhpParserErrorTest.java
@@ -224,6 +224,23 @@ public void testNowDoc_06() throws Exception {
         checkErrors("testfiles/parser/nowdoc_06.php");
     }
 
+    // HEREDOC
+    public void testNetBeans1563_01() throws Exception {
+        checkErrors("testfiles/parser/netbeans1563_01.php");
+    }
+
+    public void testNetBeans1563_02() throws Exception {
+        checkErrors("testfiles/parser/netbeans1563_02.php");
+    }
+
+    public void testNetBeans1563_03() throws Exception {
+        checkErrors("testfiles/parser/netbeans1563_03.php");
+    }
+
+    public void testNetBeans1563_04() throws Exception {
+        checkErrors("testfiles/parser/netbeans1563_04.php");
+    }
+
     public void testIssue198572() throws Exception {
         // fails on Mac
         checkErrors("testfiles/parser/issue198572.php");
diff --git a/php/php.editor/tools/ASTPHP5Scanner.flex b/php/php.editor/tools/ASTPHP5Scanner.flex
index 78165c345e..a9388758de 100644
--- a/php/php.editor/tools/ASTPHP5Scanner.flex
+++ b/php/php.editor/tools/ASTPHP5Scanner.flex
@@ -1318,22 +1318,28 @@ yybegin(ST_DOCBLOCK);
             yypushback(back);
             yybegin(ST_END_HEREDOC);
         } else {
-            int indexOfVariable1 = yytext().indexOf("$");
-            int indexOfVariable2 = yytext().indexOf("{$");
-            if (indexOfVariable1 > 0 && indexOfVariable2 == -1) {
-                yypushback(yylength() - indexOfVariable1);
-                updateHeredocBodyInfo();
-                return createFullHeredocBodySymbol();
-            } else if (indexOfVariable2 > 0 && indexOfVariable1 == -1) {
-                yypushback(yylength() - indexOfVariable2);
-                updateHeredocBodyInfo();
-                return createFullHeredocBodySymbol();
-            } else if (indexOfVariable1 > 0 && indexOfVariable2 > 0) {
-                yypushback(yylength() - Math.min(indexOfVariable1, indexOfVariable2));
+            // handle variable
+            char previousChar = ' ';
+            int indexOfVariable = -1;
+            for (int i = 0; i < yylength(); i++) {
+                char currentChar = yytext().charAt(i);
+                if (currentChar == '$' && previousChar == '{') {
+                    indexOfVariable = i - 1;
+                    break;
+                }
+                if (currentChar == '$' && previousChar != '\\') {
+                    indexOfVariable = i;
+                    break;
+                }
+                previousChar = currentChar;
+            }
+
+            if (indexOfVariable == -1) {
+                yypushback(trailingNewLineLength);
+            } else {
+                yypushback(yylength() - indexOfVariable);
                 updateHeredocBodyInfo();
                 return createFullHeredocBodySymbol();
-            } else {
-                yypushback(trailingNewLineLength);
             }
         }
         updateHeredocBodyInfo();
@@ -1344,6 +1350,14 @@ yybegin(ST_DOCBLOCK);
 
     {HEREDOC_CHARS} {
         /* <ST_HEREDOC> {HEREDOC_CHARS} */
+        int indexOfNewline = yytext().indexOf("\r");
+        if (indexOfNewline == -1) {
+            indexOfNewline = yytext().indexOf("\n");
+        }
+        if (indexOfNewline > 0) {
+            // if index equals 0, don't pushback (infinite loop)
+            yypushback(yylength() - indexOfNewline);
+        }
         updateHeredocBodyInfo();
     }
 
diff --git a/php/php.editor/tools/Php5ColoringScanner.flex b/php/php.editor/tools/Php5ColoringScanner.flex
index 23879167a3..58963a14c8 100644
--- a/php/php.editor/tools/Php5ColoringScanner.flex
+++ b/php/php.editor/tools/Php5ColoringScanner.flex
@@ -1247,25 +1247,41 @@ PHP_TYPE_OBJECT=[o][b][j][e][c][t]
             yypushback(back);
             yybegin(ST_PHP_END_HEREDOC);
         } else {
-            int indexOfVariable1 = yytext().indexOf("$");
-            int indexOfVariable2 = yytext().indexOf("{$");
-            if (indexOfVariable1 > 0 && indexOfVariable2 == -1) {
-                yypushback(yylength() - indexOfVariable1);
-                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
-            } else if (indexOfVariable2 > 0 && indexOfVariable1 == -1) {
-                yypushback(yylength() - indexOfVariable2);
-                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
-            } else if (indexOfVariable1 > 0 && indexOfVariable2 > 0) {
-                yypushback(yylength() - Math.min(indexOfVariable1, indexOfVariable2));
-                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
-            } else {
+            // handle variable
+            char previousChar = ' ';
+            int indexOfVariable = -1;
+            for (int i = 0; i < yylength(); i++) {
+                char currentChar = yytext().charAt(i);
+                if (currentChar == '$' && previousChar == '{') {
+                    indexOfVariable = i - 1;
+                    break;
+                }
+                if (currentChar == '$' && previousChar != '\\') {
+                    indexOfVariable = i;
+                    break;
+                }
+                previousChar = currentChar;
+            }
+
+            if (indexOfVariable == -1) {
                 yypushback(trailingNewLineLength);
+            } else {
+                yypushback(yylength() - indexOfVariable);
+                return PHPTokenId.PHP_ENCAPSED_AND_WHITESPACE;
             }
         }
         return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
     }
 
     {HEREDOC_CHARS} {
+        int indexOfNewline = yytext().indexOf("\r");
+        if (indexOfNewline == -1) {
+            indexOfNewline = yytext().indexOf("\n");
+        }
+        if (indexOfNewline > 0) {
+            // if index equals 0, don't pushback (infinite loop)
+            yypushback(yylength() - indexOfNewline);
+        }
         return PHPTokenId.PHP_CONSTANT_ENCAPSED_STRING;
     }
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists