From f2000cbae0d4de69074ca013660ec691512655b8 Mon Sep 17 00:00:00 2001 From: tangzx <love.tangzx@qq.com> Date: Fri, 13 Mar 2020 17:37:27 +0800 Subject: [PATCH] fix performance issue!!! --- .../tang/intellij/lua/lexer/_LuaLexer.java | 677 +++++++++--------- .../main/java/com/tang/intellij/lua/lua.flex | 73 +- 2 files changed, 367 insertions(+), 383 deletions(-) diff --git a/EmmyLua-Common/src/main/gen/com/tang/intellij/lua/lexer/_LuaLexer.java b/EmmyLua-Common/src/main/gen/com/tang/intellij/lua/lexer/_LuaLexer.java index e9f20eb7..caf21bc8 100644 --- a/EmmyLua-Common/src/main/gen/com/tang/intellij/lua/lexer/_LuaLexer.java +++ b/EmmyLua-Common/src/main/gen/com/tang/intellij/lua/lexer/_LuaLexer.java @@ -41,7 +41,7 @@ public class _LuaLexer implements FlexLexer { * l is of the form l = 2*k, k a non negative integer */ private static final int ZZ_LEXSTATE[] = { - 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 + 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4 }; /** @@ -77,24 +77,23 @@ public static int ZZ_CMAP(int ch) { private static final int [] ZZ_ACTION = zzUnpackAction(); private static final String ZZ_ACTION_PACKED_0 = - "\1\0\1\1\5\0\1\2\1\3\1\4\1\5\1\6"+ + "\1\0\1\1\4\0\1\2\1\3\1\4\1\5\1\6"+ "\1\5\1\7\1\10\6\4\1\11\1\4\1\12\1\13"+ "\1\14\1\15\1\16\1\17\7\4\1\20\1\21\1\22"+ "\1\23\1\24\1\25\1\26\1\27\1\30\1\31\1\32"+ - "\1\33\1\34\1\35\1\36\2\37\1\2\1\0\2\40"+ - "\1\5\2\0\1\5\1\0\1\5\1\41\1\42\4\4"+ - "\1\43\1\44\1\45\2\4\1\46\1\47\1\0\1\50"+ - "\12\4\1\51\1\52\1\53\1\54\1\55\1\56\1\57"+ - "\1\60\1\37\4\0\1\61\2\0\3\5\1\62\4\0"+ - "\2\4\1\63\2\4\1\64\1\65\1\66\2\4\1\67"+ - "\6\4\1\0\1\61\1\70\1\0\1\5\6\0\2\4"+ - "\1\71\1\72\5\4\1\73\1\74\1\4\1\75\2\0"+ - "\1\76\1\5\2\0\1\77\1\100\3\4\1\101\1\102"+ - "\1\103\1\4\1\104\1\105\1\0\1\5\2\0\1\106"+ - "\1\107\1\110\1\4\3\0\1\4\1\0\1\111\2\0"; + "\1\33\1\34\1\35\1\36\2\37\1\0\1\5\2\0"+ + "\1\5\1\0\1\5\1\40\1\41\4\4\1\42\1\43"+ + "\1\44\2\4\1\45\1\46\12\4\1\47\1\50\1\51"+ + "\1\52\1\53\1\54\1\55\1\56\1\37\2\0\1\57"+ + "\1\0\3\5\1\60\4\0\2\4\1\61\2\4\1\62"+ + "\1\63\1\64\2\4\1\65\6\4\1\57\1\66\1\5"+ + "\6\0\2\4\1\67\1\70\5\4\1\71\1\72\1\4"+ + "\2\0\1\5\2\0\1\73\1\74\3\4\1\75\1\76"+ + "\1\77\1\4\1\100\1\101\1\0\1\5\2\0\1\102"+ + "\1\103\1\104\1\4\3\0\1\4\1\0\1\105\2\0"; private static int [] zzUnpackAction() { - int [] result = new int[186]; + int [] result = new int[173]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -119,33 +118,31 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { private static final int [] ZZ_ROWMAP = zzUnpackRowMap(); private static final String ZZ_ROWMAP_PACKED_0 = - "\0\0\0\75\0\172\0\267\0\364\0\u0131\0\u016e\0\u01ab"+ - "\0\u01e8\0\u0225\0\u0262\0\u01ab\0\u029f\0\u02dc\0\u0319\0\u0356"+ - "\0\u0393\0\u03d0\0\u040d\0\u044a\0\u0487\0\u01ab\0\u04c4\0\u01ab"+ - "\0\u0501\0\u053e\0\u01ab\0\u01ab\0\u01ab\0\u057b\0\u05b8\0\u05f5"+ - "\0\u0632\0\u066f\0\u06ac\0\u06e9\0\u0726\0\u0763\0\u07a0\0\u07dd"+ - "\0\u01ab\0\u01ab\0\u081a\0\u01ab\0\u01ab\0\u01ab\0\u01ab\0\u0857"+ - "\0\u01ab\0\u01ab\0\u01ab\0\u0894\0\u08d1\0\u090e\0\u094b\0\u01ab"+ - "\0\u0988\0\u09c5\0\u0a02\0\u0a3f\0\u0a7c\0\u0ab9\0\u0af6\0\u0b33"+ - "\0\u0b70\0\u0bad\0\u0bea\0\u0c27\0\u0c64\0\u0225\0\u0225\0\u0225"+ - "\0\u0ca1\0\u0cde\0\u0225\0\u01ab\0\u0501\0\u01ab\0\u0d1b\0\u0d58"+ - "\0\u0d95\0\u0dd2\0\u0e0f\0\u0e4c\0\u0e89\0\u0ec6\0\u0f03\0\u0f40"+ - "\0\u01ab\0\u01ab\0\u01ab\0\u01ab\0\u01ab\0\u01ab\0\u01ab\0\u01ab"+ - "\0\u01ab\0\u0f7d\0\u0fba\0\u0ff7\0\u090e\0\u1034\0\u1071\0\u0af6"+ - "\0\u01ab\0\u10ae\0\u10eb\0\u01ab\0\u1128\0\u1165\0\u11a2\0\u11df"+ - "\0\u121c\0\u1259\0\u0225\0\u1296\0\u12d3\0\u0225\0\u0225\0\u0225"+ - "\0\u1310\0\u134d\0\u0225\0\u138a\0\u13c7\0\u1404\0\u1441\0\u147e"+ - "\0\u14bb\0\u14f8\0\u1535\0\u1572\0\u15af\0\u15ec\0\u1629\0\u1666"+ - "\0\u16a3\0\u16e0\0\u171d\0\u175a\0\u1797\0\u17d4\0\u1811\0\u0225"+ - "\0\u184e\0\u188b\0\u18c8\0\u1905\0\u1942\0\u0225\0\u0225\0\u197f"+ - "\0\u14f8\0\u19bc\0\u19f9\0\u1a36\0\u1a73\0\u1ab0\0\u1aed\0\u1b2a"+ - "\0\u1b67\0\u1ba4\0\u1be1\0\u1c1e\0\u0225\0\u0225\0\u0225\0\u1c5b"+ - "\0\u0225\0\u0225\0\u1c98\0\u1cd5\0\u1d12\0\u1d4f\0\u0225\0\u0225"+ - "\0\u0225\0\u1d8c\0\u1dc9\0\u1e06\0\u1e43\0\u1e80\0\u1ebd\0\u0225"+ - "\0\u1efa\0\u1f37"; + "\0\0\0\75\0\172\0\267\0\364\0\u0131\0\364\0\u016e"+ + "\0\u01ab\0\u01e8\0\364\0\u0225\0\u0262\0\u029f\0\u02dc\0\u0319"+ + "\0\u0356\0\u0393\0\u03d0\0\u040d\0\364\0\u044a\0\364\0\364"+ + "\0\u0487\0\364\0\364\0\364\0\u04c4\0\u0501\0\u053e\0\u057b"+ + "\0\u05b8\0\u05f5\0\u0632\0\u066f\0\u06ac\0\u06e9\0\u0726\0\364"+ + "\0\364\0\u0763\0\364\0\364\0\364\0\364\0\u07a0\0\364"+ + "\0\364\0\364\0\u07dd\0\u081a\0\u0857\0\u0894\0\u08d1\0\u090e"+ + "\0\u094b\0\u0988\0\u09c5\0\u0a02\0\u0a3f\0\u0a7c\0\u0ab9\0\u0af6"+ + "\0\u0b33\0\u01ab\0\u01ab\0\u01ab\0\u0b70\0\u0bad\0\u01ab\0\364"+ + "\0\u0bea\0\u0c27\0\u0c64\0\u0ca1\0\u0cde\0\u0d1b\0\u0d58\0\u0d95"+ + "\0\u0dd2\0\u0e0f\0\364\0\364\0\364\0\364\0\364\0\364"+ + "\0\364\0\364\0\364\0\u0e4c\0\u0e89\0\u0ec6\0\u09c5\0\364"+ + "\0\u0f03\0\u0f40\0\364\0\u0f7d\0\u0fba\0\u0ff7\0\u1034\0\u1071"+ + "\0\u10ae\0\u01ab\0\u10eb\0\u1128\0\u01ab\0\u01ab\0\u01ab\0\u1165"+ + "\0\u11a2\0\u01ab\0\u11df\0\u121c\0\u1259\0\u1296\0\u12d3\0\u1310"+ + "\0\u134d\0\u138a\0\u13c7\0\u1404\0\u1441\0\u147e\0\u14bb\0\u14f8"+ + "\0\u1535\0\u1572\0\u15af\0\u15ec\0\u01ab\0\u1629\0\u1666\0\u16a3"+ + "\0\u16e0\0\u171d\0\u01ab\0\u01ab\0\u175a\0\u1797\0\u17d4\0\u1811"+ + "\0\u184e\0\u188b\0\u18c8\0\u1905\0\u1942\0\u197f\0\u19bc\0\u01ab"+ + "\0\u01ab\0\u01ab\0\u19f9\0\u01ab\0\u01ab\0\u1a36\0\u1a73\0\u1ab0"+ + "\0\u1aed\0\u01ab\0\u01ab\0\u01ab\0\u1b2a\0\u1b67\0\u1ba4\0\u1be1"+ + "\0\u1c1e\0\u1c5b\0\u01ab\0\u1c98\0\u1cd5"; private static int [] zzUnpackRowMap() { - int [] result = new int[186]; + int [] result = new int[173]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -168,157 +165,154 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { private static final int [] ZZ_TRANS = zzUnpackTrans(); private static final String ZZ_TRANS_PACKED_0 = - "\1\10\3\11\1\12\1\13\2\12\1\14\1\12\1\15"+ - "\3\12\1\16\1\17\1\20\1\21\1\22\1\23\1\24"+ - "\1\25\1\26\1\27\1\30\1\31\1\32\1\33\1\34"+ - "\2\10\1\12\1\35\1\36\1\37\1\12\1\40\1\12"+ - "\1\41\1\42\1\12\1\43\2\12\1\44\1\45\1\10"+ - "\1\46\1\47\1\50\1\51\1\52\1\53\1\54\1\55"+ - "\1\56\1\57\1\60\1\61\1\62\1\63\1\2\2\0"+ - "\72\2\34\0\1\64\100\0\1\65\34\0\31\10\1\66"+ - "\43\10\17\0\1\67\55\0\17\70\1\71\55\70\76\0"+ - "\3\11\75\0\4\12\1\0\5\12\2\0\6\12\1\0"+ - "\1\12\7\0\1\12\1\0\14\12\25\0\1\13\1\0"+ - "\1\72\2\0\1\13\1\0\1\73\1\74\1\75\2\0"+ - "\1\72\60\0\1\13\1\0\1\72\2\0\1\13\1\76"+ - "\1\73\1\74\1\75\2\0\1\72\60\0\1\77\4\0"+ - "\1\77\3\0\1\100\75\0\1\101\61\0\4\12\1\0"+ - "\5\12\2\0\1\12\1\102\4\12\1\0\1\12\7\0"+ - "\1\12\1\0\14\12\24\0\4\12\1\0\5\12\2\0"+ - "\5\12\1\103\1\0\1\12\7\0\1\12\1\0\3\12"+ - "\1\104\10\12\24\0\4\12\1\0\5\12\2\0\4\12"+ - "\1\105\1\12\1\0\1\12\7\0\1\12\1\0\14\12"+ - "\24\0\4\12\1\0\5\12\2\0\5\12\1\106\1\0"+ - "\1\12\7\0\1\12\1\0\5\12\1\107\6\12\24\0"+ - "\4\12\1\0\5\12\2\0\1\110\5\12\1\0\1\12"+ - "\7\0\1\12\1\0\14\12\24\0\4\12\1\0\5\12"+ - "\2\0\3\12\1\111\1\112\1\12\1\0\1\12\7\0"+ - "\1\12\1\0\14\12\24\0\4\12\1\0\5\12\2\0"+ - "\4\12\1\113\1\12\1\0\1\12\7\0\1\12\1\0"+ - "\14\12\51\0\1\114\1\115\74\0\1\116\46\0\4\12"+ - "\1\0\5\12\2\0\5\12\1\117\1\0\1\12\7\0"+ - "\1\12\1\0\14\12\24\0\4\12\1\0\5\12\2\0"+ - "\1\120\5\12\1\0\1\12\7\0\1\12\1\0\14\12"+ - "\24\0\4\12\1\0\5\12\2\0\4\12\1\121\1\12"+ - "\1\0\1\12\7\0\1\12\1\0\14\12\24\0\4\12"+ - "\1\0\5\12\2\0\4\12\1\122\1\12\1\0\1\12"+ - "\7\0\1\12\1\0\1\123\5\12\1\124\5\12\24\0"+ - "\4\12\1\0\5\12\2\0\5\12\1\125\1\0\1\12"+ - "\7\0\1\12\1\0\14\12\24\0\4\12\1\0\5\12"+ - "\2\0\1\126\5\12\1\0\1\12\7\0\1\12\1\0"+ - "\12\12\1\127\1\12\24\0\4\12\1\0\5\12\2\0"+ - "\6\12\1\0\1\12\7\0\1\12\1\0\12\12\1\130"+ - "\1\12\76\0\1\131\50\0\1\132\24\0\1\133\47\0"+ - "\1\134\25\0\1\135\46\0\1\136\126\0\1\137\101\0"+ - "\1\140\3\0\34\64\1\141\1\142\37\64\35\65\1\143"+ - "\2\65\1\141\34\65\31\0\1\144\1\145\61\0\1\146"+ - "\74\0\1\147\62\0\1\77\2\0\1\150\1\0\1\77"+ - "\4\0\1\150\72\0\1\74\74\0\1\151\64\0\1\152"+ - "\4\0\1\152\67\0\3\153\2\0\1\153\6\0\1\153"+ - "\5\0\1\153\11\0\2\153\3\0\1\153\1\0\1\153"+ - "\31\0\1\77\4\0\1\77\100\0\1\154\76\0\1\155"+ - "\1\156\4\0\1\157\1\0\1\160\50\0\4\12\1\0"+ - "\5\12\2\0\6\12\1\0\1\12\7\0\1\12\1\0"+ - "\10\12\1\161\1\162\2\12\24\0\4\12\1\0\5\12"+ - "\2\0\6\12\1\0\1\163\7\0\1\12\1\0\14\12"+ - "\24\0\4\12\1\0\5\12\2\0\6\12\1\0\1\12"+ - "\7\0\1\12\1\0\4\12\1\164\7\12\24\0\4\12"+ - "\1\0\5\12\2\0\6\12\1\0\1\12\7\0\1\12"+ - "\1\0\10\12\1\165\3\12\24\0\4\12\1\0\5\12"+ - "\2\0\6\12\1\0\1\12\7\0\1\12\1\0\3\12"+ - "\1\166\10\12\24\0\4\12\1\0\5\12\2\0\6\12"+ - "\1\0\1\12\7\0\1\12\1\0\10\12\1\167\3\12"+ - "\24\0\4\12\1\0\5\12\2\0\6\12\1\0\1\170"+ - "\7\0\1\12\1\0\14\12\24\0\4\12\1\0\5\12"+ - "\2\0\1\12\1\171\4\12\1\0\1\12\7\0\1\12"+ - "\1\0\14\12\24\0\4\12\1\0\5\12\2\0\6\12"+ - "\1\0\1\12\7\0\1\12\1\0\7\12\1\172\4\12"+ - "\24\0\4\12\1\0\5\12\2\0\1\173\5\12\1\0"+ - "\1\12\7\0\1\12\1\0\14\12\24\0\4\12\1\0"+ - "\5\12\2\0\6\12\1\0\1\12\7\0\1\12\1\0"+ - "\3\12\1\174\10\12\24\0\4\12\1\0\5\12\2\0"+ - "\5\12\1\175\1\0\1\12\7\0\1\12\1\0\14\12"+ - "\24\0\4\12\1\0\5\12\2\0\6\12\1\0\1\12"+ - "\7\0\1\12\1\0\10\12\1\176\3\12\24\0\4\12"+ - "\1\0\5\12\2\0\6\12\1\0\1\12\7\0\1\12"+ - "\1\0\6\12\1\177\5\12\24\0\4\12\1\0\5\12"+ - "\2\0\1\12\1\200\4\12\1\0\1\12\7\0\1\12"+ - "\1\0\14\12\24\0\4\12\1\0\5\12\2\0\3\12"+ - "\1\201\2\12\1\0\1\12\7\0\1\12\1\0\14\12"+ - "\21\0\2\64\2\0\70\64\1\0\2\65\2\0\70\65"+ - "\33\144\1\202\41\144\1\203\2\0\14\203\1\204\55\203"+ - "\31\0\1\205\50\0\1\152\1\0\1\72\2\0\1\152"+ - "\6\0\1\72\60\0\2\153\1\206\1\0\1\207\1\153"+ - "\1\0\1\73\1\74\1\210\2\0\1\206\5\0\1\153"+ - "\11\0\2\153\3\0\1\153\1\0\1\153\1\0\1\207"+ - "\43\0\1\211\100\0\1\212\75\0\1\213\76\0\1\214"+ - "\50\0\4\12\1\0\5\12\2\0\6\12\1\0\1\12"+ - "\7\0\1\12\1\0\6\12\1\215\5\12\24\0\4\12"+ - "\1\0\5\12\2\0\1\12\1\216\4\12\1\0\1\12"+ - "\7\0\1\12\1\0\14\12\24\0\4\12\1\0\5\12"+ - "\2\0\1\12\1\217\4\12\1\0\1\12\7\0\1\12"+ - "\1\0\14\12\24\0\4\12\1\0\5\12\2\0\4\12"+ - "\1\220\1\12\1\0\1\12\7\0\1\12\1\0\14\12"+ - "\24\0\4\12\1\0\5\12\2\0\6\12\1\0\1\12"+ - "\7\0\1\12\1\0\1\221\13\12\24\0\4\12\1\0"+ - "\5\12\2\0\6\12\1\0\1\12\7\0\1\12\1\0"+ - "\1\222\13\12\24\0\4\12\1\0\5\12\2\0\6\12"+ - "\1\0\1\12\7\0\1\12\1\0\4\12\1\223\7\12"+ - "\24\0\4\12\1\0\5\12\2\0\6\12\1\0\1\12"+ - "\7\0\1\12\1\0\7\12\1\224\4\12\24\0\4\12"+ - "\1\0\5\12\2\0\3\12\1\225\2\12\1\0\1\12"+ - "\7\0\1\12\1\0\14\12\24\0\4\12\1\0\5\12"+ - "\2\0\1\12\1\226\4\12\1\0\1\12\7\0\1\12"+ - "\1\0\14\12\24\0\4\12\1\0\5\12\2\0\5\12"+ - "\1\227\1\0\1\12\7\0\1\12\1\0\14\12\24\0"+ - "\4\12\1\0\5\12\2\0\6\12\1\0\1\12\7\0"+ - "\1\12\1\0\3\12\1\230\10\12\20\0\32\144\1\202"+ - "\1\231\41\144\1\203\2\0\72\203\1\204\1\232\1\233"+ - "\72\204\31\0\1\234\1\205\47\0\2\153\1\206\1\150"+ - "\1\207\1\153\1\0\1\73\1\74\1\210\1\150\1\0"+ - "\1\206\5\0\1\153\11\0\2\153\3\0\1\153\1\0"+ - "\1\153\1\0\1\207\32\0\1\150\6\0\1\150\62\0"+ - "\3\235\2\0\1\235\6\0\1\235\5\0\1\235\11\0"+ - "\2\235\3\0\1\235\1\0\1\235\46\0\1\236\101\0"+ - "\1\237\73\0\1\240\76\0\1\241\50\0\4\12\1\0"+ - "\5\12\2\0\1\242\5\12\1\0\1\12\7\0\1\12"+ - "\1\0\14\12\24\0\4\12\1\0\5\12\2\0\6\12"+ - "\1\0\1\12\7\0\1\12\1\0\1\243\13\12\24\0"+ - "\4\12\1\0\5\12\2\0\3\12\1\244\2\12\1\0"+ - "\1\12\7\0\1\12\1\0\14\12\24\0\4\12\1\0"+ - "\5\12\2\0\6\12\1\0\1\12\7\0\1\12\1\0"+ - "\2\12\1\245\11\12\24\0\4\12\1\0\5\12\2\0"+ - "\6\12\1\0\1\12\7\0\1\12\1\0\3\12\1\246"+ - "\10\12\24\0\4\12\1\0\5\12\2\0\1\12\1\247"+ - "\4\12\1\0\1\12\7\0\1\12\1\0\14\12\24\0"+ - "\4\12\1\0\5\12\2\0\6\12\1\0\1\12\7\0"+ - "\1\12\1\0\10\12\1\250\3\12\24\0\4\12\1\0"+ - "\5\12\2\0\6\12\1\0\1\12\7\0\1\12\1\0"+ - "\3\12\1\251\10\12\24\0\4\12\1\0\5\12\2\0"+ - "\1\12\1\252\4\12\1\0\1\12\7\0\1\12\1\0"+ - "\14\12\22\0\1\233\75\0\1\233\13\0\1\253\55\0"+ - "\75\234\5\0\2\235\1\254\1\0\1\207\1\235\6\0"+ - "\1\254\5\0\1\235\11\0\2\235\3\0\1\235\1\0"+ - "\1\235\1\0\1\207\45\0\1\255\71\0\1\256\54\0"+ - "\1\240\2\0\72\240\1\241\2\0\72\241\4\0\4\12"+ - "\1\0\5\12\2\0\5\12\1\257\1\0\1\12\7\0"+ - "\1\12\1\0\14\12\24\0\4\12\1\0\5\12\2\0"+ - "\6\12\1\0\1\12\7\0\1\12\1\0\10\12\1\260"+ - "\3\12\24\0\4\12\1\0\5\12\2\0\6\12\1\0"+ - "\1\12\7\0\1\12\1\0\5\12\1\261\6\12\24\0"+ - "\4\12\1\0\5\12\2\0\3\12\1\262\2\12\1\0"+ - "\1\12\7\0\1\12\1\0\14\12\37\0\1\263\62\0"+ - "\2\235\1\254\1\150\1\207\1\235\4\0\1\150\1\0"+ - "\1\254\5\0\1\235\11\0\2\235\3\0\1\235\1\0"+ - "\1\235\1\0\1\207\46\0\1\264\71\0\1\265\57\0"+ - "\4\12\1\0\5\12\2\0\4\12\1\266\1\12\1\0"+ - "\1\12\7\0\1\12\1\0\14\12\37\0\1\204\102\0"+ - "\1\240\71\0\1\267\56\0\4\12\1\0\5\12\2\0"+ - "\5\12\1\270\1\0\1\12\7\0\1\12\1\0\14\12"+ - "\43\0\1\271\75\0\1\272\75\0\1\241\47\0"; + "\1\7\3\10\1\11\1\12\2\11\1\13\1\11\1\14"+ + "\3\11\1\15\1\16\1\17\1\20\1\21\1\22\1\23"+ + "\1\24\1\25\1\26\1\27\1\30\1\31\1\32\1\33"+ + "\2\7\1\11\1\34\1\35\1\36\1\11\1\37\1\11"+ + "\1\40\1\41\1\11\1\42\2\11\1\43\1\44\1\7"+ + "\1\45\1\46\1\47\1\50\1\51\1\52\1\53\1\54"+ + "\1\55\1\56\1\57\1\60\1\61\1\62\1\2\2\0"+ + "\72\2\34\0\1\63\100\0\1\64\150\0\1\65\56\0"+ + "\3\10\75\0\4\11\1\0\5\11\2\0\6\11\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\25\0\1\12\1\0"+ + "\1\66\2\0\1\12\1\0\1\67\1\70\1\71\2\0"+ + "\1\66\60\0\1\12\1\0\1\66\2\0\1\12\1\72"+ + "\1\67\1\70\1\71\2\0\1\66\60\0\1\73\4\0"+ + "\1\73\3\0\1\74\75\0\1\75\61\0\4\11\1\0"+ + "\5\11\2\0\1\11\1\76\4\11\1\0\1\11\7\0"+ + "\1\11\1\0\14\11\24\0\4\11\1\0\5\11\2\0"+ + "\5\11\1\77\1\0\1\11\7\0\1\11\1\0\3\11"+ + "\1\100\10\11\24\0\4\11\1\0\5\11\2\0\4\11"+ + "\1\101\1\11\1\0\1\11\7\0\1\11\1\0\14\11"+ + "\24\0\4\11\1\0\5\11\2\0\5\11\1\102\1\0"+ + "\1\11\7\0\1\11\1\0\5\11\1\103\6\11\24\0"+ + "\4\11\1\0\5\11\2\0\1\104\5\11\1\0\1\11"+ + "\7\0\1\11\1\0\14\11\24\0\4\11\1\0\5\11"+ + "\2\0\3\11\1\105\1\106\1\11\1\0\1\11\7\0"+ + "\1\11\1\0\14\11\24\0\4\11\1\0\5\11\2\0"+ + "\4\11\1\107\1\11\1\0\1\11\7\0\1\11\1\0"+ + "\14\11\52\0\1\110\46\0\4\11\1\0\5\11\2\0"+ + "\5\11\1\111\1\0\1\11\7\0\1\11\1\0\14\11"+ + "\24\0\4\11\1\0\5\11\2\0\1\112\5\11\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\24\0\4\11\1\0"+ + "\5\11\2\0\4\11\1\113\1\11\1\0\1\11\7\0"+ + "\1\11\1\0\14\11\24\0\4\11\1\0\5\11\2\0"+ + "\4\11\1\114\1\11\1\0\1\11\7\0\1\11\1\0"+ + "\1\115\5\11\1\116\5\11\24\0\4\11\1\0\5\11"+ + "\2\0\5\11\1\117\1\0\1\11\7\0\1\11\1\0"+ + "\14\11\24\0\4\11\1\0\5\11\2\0\1\120\5\11"+ + "\1\0\1\11\7\0\1\11\1\0\12\11\1\121\1\11"+ + "\24\0\4\11\1\0\5\11\2\0\6\11\1\0\1\11"+ + "\7\0\1\11\1\0\12\11\1\122\1\11\76\0\1\123"+ + "\50\0\1\124\24\0\1\125\47\0\1\126\25\0\1\127"+ + "\46\0\1\130\126\0\1\131\101\0\1\132\3\0\34\63"+ + "\1\133\1\134\37\63\35\64\1\135\2\64\1\133\34\64"+ + "\17\0\1\136\62\0\1\73\2\0\1\137\1\0\1\73"+ + "\4\0\1\137\72\0\1\70\74\0\1\140\64\0\1\141"+ + "\4\0\1\141\67\0\3\142\2\0\1\142\6\0\1\142"+ + "\5\0\1\142\11\0\2\142\3\0\1\142\1\0\1\142"+ + "\31\0\1\73\4\0\1\73\100\0\1\143\76\0\1\144"+ + "\1\145\4\0\1\146\1\0\1\147\50\0\4\11\1\0"+ + "\5\11\2\0\6\11\1\0\1\11\7\0\1\11\1\0"+ + "\10\11\1\150\1\151\2\11\24\0\4\11\1\0\5\11"+ + "\2\0\6\11\1\0\1\152\7\0\1\11\1\0\14\11"+ + "\24\0\4\11\1\0\5\11\2\0\6\11\1\0\1\11"+ + "\7\0\1\11\1\0\4\11\1\153\7\11\24\0\4\11"+ + "\1\0\5\11\2\0\6\11\1\0\1\11\7\0\1\11"+ + "\1\0\10\11\1\154\3\11\24\0\4\11\1\0\5\11"+ + "\2\0\6\11\1\0\1\11\7\0\1\11\1\0\3\11"+ + "\1\155\10\11\24\0\4\11\1\0\5\11\2\0\6\11"+ + "\1\0\1\11\7\0\1\11\1\0\10\11\1\156\3\11"+ + "\24\0\4\11\1\0\5\11\2\0\6\11\1\0\1\157"+ + "\7\0\1\11\1\0\14\11\24\0\4\11\1\0\5\11"+ + "\2\0\1\11\1\160\4\11\1\0\1\11\7\0\1\11"+ + "\1\0\14\11\24\0\4\11\1\0\5\11\2\0\6\11"+ + "\1\0\1\11\7\0\1\11\1\0\7\11\1\161\4\11"+ + "\24\0\4\11\1\0\5\11\2\0\1\162\5\11\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\24\0\4\11\1\0"+ + "\5\11\2\0\6\11\1\0\1\11\7\0\1\11\1\0"+ + "\3\11\1\163\10\11\24\0\4\11\1\0\5\11\2\0"+ + "\5\11\1\164\1\0\1\11\7\0\1\11\1\0\14\11"+ + "\24\0\4\11\1\0\5\11\2\0\6\11\1\0\1\11"+ + "\7\0\1\11\1\0\10\11\1\165\3\11\24\0\4\11"+ + "\1\0\5\11\2\0\6\11\1\0\1\11\7\0\1\11"+ + "\1\0\6\11\1\166\5\11\24\0\4\11\1\0\5\11"+ + "\2\0\1\11\1\167\4\11\1\0\1\11\7\0\1\11"+ + "\1\0\14\11\24\0\4\11\1\0\5\11\2\0\3\11"+ + "\1\170\2\11\1\0\1\11\7\0\1\11\1\0\14\11"+ + "\21\0\2\63\2\0\70\63\1\0\2\64\2\0\70\64"+ + "\1\171\2\0\14\171\1\172\55\171\5\0\1\141\1\0"+ + "\1\66\2\0\1\141\6\0\1\66\60\0\2\142\1\173"+ + "\1\0\1\174\1\142\1\0\1\67\1\70\1\175\2\0"+ + "\1\173\5\0\1\142\11\0\2\142\3\0\1\142\1\0"+ + "\1\142\1\0\1\174\43\0\1\176\100\0\1\177\75\0"+ + "\1\200\76\0\1\201\50\0\4\11\1\0\5\11\2\0"+ + "\6\11\1\0\1\11\7\0\1\11\1\0\6\11\1\202"+ + "\5\11\24\0\4\11\1\0\5\11\2\0\1\11\1\203"+ + "\4\11\1\0\1\11\7\0\1\11\1\0\14\11\24\0"+ + "\4\11\1\0\5\11\2\0\1\11\1\204\4\11\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\24\0\4\11\1\0"+ + "\5\11\2\0\4\11\1\205\1\11\1\0\1\11\7\0"+ + "\1\11\1\0\14\11\24\0\4\11\1\0\5\11\2\0"+ + "\6\11\1\0\1\11\7\0\1\11\1\0\1\206\13\11"+ + "\24\0\4\11\1\0\5\11\2\0\6\11\1\0\1\11"+ + "\7\0\1\11\1\0\1\207\13\11\24\0\4\11\1\0"+ + "\5\11\2\0\6\11\1\0\1\11\7\0\1\11\1\0"+ + "\4\11\1\210\7\11\24\0\4\11\1\0\5\11\2\0"+ + "\6\11\1\0\1\11\7\0\1\11\1\0\7\11\1\211"+ + "\4\11\24\0\4\11\1\0\5\11\2\0\3\11\1\212"+ + "\2\11\1\0\1\11\7\0\1\11\1\0\14\11\24\0"+ + "\4\11\1\0\5\11\2\0\1\11\1\213\4\11\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\24\0\4\11\1\0"+ + "\5\11\2\0\5\11\1\214\1\0\1\11\7\0\1\11"+ + "\1\0\14\11\24\0\4\11\1\0\5\11\2\0\6\11"+ + "\1\0\1\11\7\0\1\11\1\0\3\11\1\215\10\11"+ + "\20\0\1\171\2\0\72\171\1\172\1\216\1\217\72\172"+ + "\5\0\2\142\1\173\1\137\1\174\1\142\1\0\1\67"+ + "\1\70\1\175\1\137\1\0\1\173\5\0\1\142\11\0"+ + "\2\142\3\0\1\142\1\0\1\142\1\0\1\174\32\0"+ + "\1\137\6\0\1\137\62\0\3\220\2\0\1\220\6\0"+ + "\1\220\5\0\1\220\11\0\2\220\3\0\1\220\1\0"+ + "\1\220\46\0\1\221\101\0\1\222\73\0\1\223\76\0"+ + "\1\224\50\0\4\11\1\0\5\11\2\0\1\225\5\11"+ + "\1\0\1\11\7\0\1\11\1\0\14\11\24\0\4\11"+ + "\1\0\5\11\2\0\6\11\1\0\1\11\7\0\1\11"+ + "\1\0\1\226\13\11\24\0\4\11\1\0\5\11\2\0"+ + "\3\11\1\227\2\11\1\0\1\11\7\0\1\11\1\0"+ + "\14\11\24\0\4\11\1\0\5\11\2\0\6\11\1\0"+ + "\1\11\7\0\1\11\1\0\2\11\1\230\11\11\24\0"+ + "\4\11\1\0\5\11\2\0\6\11\1\0\1\11\7\0"+ + "\1\11\1\0\3\11\1\231\10\11\24\0\4\11\1\0"+ + "\5\11\2\0\1\11\1\232\4\11\1\0\1\11\7\0"+ + "\1\11\1\0\14\11\24\0\4\11\1\0\5\11\2\0"+ + "\6\11\1\0\1\11\7\0\1\11\1\0\10\11\1\233"+ + "\3\11\24\0\4\11\1\0\5\11\2\0\6\11\1\0"+ + "\1\11\7\0\1\11\1\0\3\11\1\234\10\11\24\0"+ + "\4\11\1\0\5\11\2\0\1\11\1\235\4\11\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\22\0\1\217\75\0"+ + "\1\217\13\0\1\236\62\0\2\220\1\237\1\0\1\174"+ + "\1\220\6\0\1\237\5\0\1\220\11\0\2\220\3\0"+ + "\1\220\1\0\1\220\1\0\1\174\45\0\1\240\71\0"+ + "\1\241\54\0\1\223\2\0\72\223\1\224\2\0\72\224"+ + "\4\0\4\11\1\0\5\11\2\0\5\11\1\242\1\0"+ + "\1\11\7\0\1\11\1\0\14\11\24\0\4\11\1\0"+ + "\5\11\2\0\6\11\1\0\1\11\7\0\1\11\1\0"+ + "\10\11\1\243\3\11\24\0\4\11\1\0\5\11\2\0"+ + "\6\11\1\0\1\11\7\0\1\11\1\0\5\11\1\244"+ + "\6\11\24\0\4\11\1\0\5\11\2\0\3\11\1\245"+ + "\2\11\1\0\1\11\7\0\1\11\1\0\14\11\37\0"+ + "\1\246\62\0\2\220\1\237\1\137\1\174\1\220\4\0"+ + "\1\137\1\0\1\237\5\0\1\220\11\0\2\220\3\0"+ + "\1\220\1\0\1\220\1\0\1\174\46\0\1\247\71\0"+ + "\1\250\57\0\4\11\1\0\5\11\2\0\4\11\1\251"+ + "\1\11\1\0\1\11\7\0\1\11\1\0\14\11\37\0"+ + "\1\172\102\0\1\223\71\0\1\252\56\0\4\11\1\0"+ + "\5\11\2\0\5\11\1\253\1\0\1\11\7\0\1\11"+ + "\1\0\14\11\43\0\1\254\75\0\1\255\75\0\1\224"+ + "\47\0"; private static int [] zzUnpackTrans() { - int [] result = new int[8052]; + int [] result = new int[7442]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -356,17 +350,16 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\1\5\0\1\11\3\1\1\11\11\1\1\11"+ - "\1\1\1\11\2\1\3\11\13\1\2\11\1\1\4\11"+ - "\1\1\3\11\3\1\1\0\1\11\2\1\2\0\1\1"+ - "\1\0\15\1\1\11\1\0\1\11\12\1\11\11\4\0"+ - "\1\1\2\0\1\11\2\1\1\11\4\0\21\1\1\0"+ - "\2\1\1\0\1\1\6\0\15\1\2\0\2\1\2\0"+ - "\13\1\1\0\1\1\2\0\4\1\3\0\1\1\1\0"+ - "\1\1\2\0"; + "\1\0\1\1\2\0\1\10\1\0\1\11\3\1\1\11"+ + "\11\1\1\11\1\1\2\11\1\1\3\11\13\1\2\11"+ + "\1\1\4\11\1\1\3\11\2\1\1\0\1\1\2\0"+ + "\1\1\1\0\15\1\1\11\12\1\11\11\2\0\1\1"+ + "\1\0\1\11\2\1\1\11\4\0\24\1\6\0\14\1"+ + "\2\0\1\1\2\0\13\1\1\0\1\1\2\0\4\1"+ + "\3\0\1\1\1\0\1\1\2\0"; private static int [] zzUnpackAttribute() { - int [] result = new int[186]; + int [] result = new int[173]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -446,16 +439,27 @@ private boolean checkBlock() { return false; } - private int checkBlockRedundant() { - int redundant = -1; - String cs = yytext().toString(); - StringBuilder s = new StringBuilder("]"); - for (int i = 0; i < nBrackets; i++) s.append('='); - s.append(']'); - int index = cs.indexOf(s.toString()); - if (index > 0) - redundant = yylength() - index - nBrackets - 2; - return redundant; + private int checkBlockEnd() { + int pos = zzMarkedPos; + int end = zzEndRead; + while(pos < end) { + char c = zzBuffer.charAt(pos); + if (c == ']') { + pos++; + int size = 0; + while (pos < zzEndRead && zzBuffer.charAt(pos) == '=') { + size++; + pos++; + } + if (size == nBrackets && zzBuffer.charAt(pos) == ']') { + pos++; + break; + } + continue; + } + pos++; + } + return pos - zzMarkedPos; } @@ -571,7 +575,7 @@ public final int yylength() { /** - * Reports an error that occurred while scanning. + * Reports an error that occured while scanning. * * In a wellformed scanner (no or only correct usage of * yypushback(int) and a match-all fallback rule) this method @@ -707,379 +711,360 @@ else if (zzAtEOF) { { yybegin(YYINITIAL); return SHEBANG_CONTENT; } // fall through - case 74: break; + case 70: break; case 2: { return TokenType.BAD_CHARACTER; } // fall through - case 75: break; + case 71: break; case 3: { return TokenType.WHITE_SPACE; } // fall through - case 76: break; + case 72: break; case 4: { return ID; } // fall through - case 77: break; + case 73: break; case 5: { return NUMBER; } // fall through - case 78: break; + case 74: break; case 6: { return PLUS; } // fall through - case 79: break; + case 75: break; case 7: { return DOT; } // fall through - case 80: break; + case 76: break; case 8: { return MINUS; } // fall through - case 81: break; + case 77: break; case 9: { return LCURLY; } // fall through - case 82: break; + case 78: break; case 10: { return RCURLY; } // fall through - case 83: break; + case 79: break; case 11: - { return LBRACK; + { if (checkAhead('=', 0) || checkAhead('[', 0)) { + yypushback(yylength()); + checkBlock(); + zzMarkedPos += checkBlockEnd(); + return STRING; + } else { + return LBRACK; + } } // fall through - case 84: break; + case 80: break; case 12: { return ASSIGN; } // fall through - case 85: break; + case 81: break; case 13: { return RBRACK; } // fall through - case 86: break; + case 82: break; case 14: { yybegin(xDOUBLE_QUOTED_STRING); yypushback(yylength()); } // fall through - case 87: break; + case 83: break; case 15: { yybegin(xSINGLE_QUOTED_STRING); yypushback(yylength()); } // fall through - case 88: break; + case 84: break; case 16: { return GETN; } // fall through - case 89: break; + case 85: break; case 17: { return GT; } // fall through - case 90: break; + case 86: break; case 18: { return LT; } // fall through - case 91: break; + case 87: break; case 19: { return BIT_TILDE; } // fall through - case 92: break; + case 88: break; case 20: { return MULT; } // fall through - case 93: break; + case 89: break; case 21: { return MOD; } // fall through - case 94: break; + case 90: break; case 22: { return DIV; } // fall through - case 95: break; + case 91: break; case 23: { return LPAREN; } // fall through - case 96: break; + case 92: break; case 24: { return RPAREN; } // fall through - case 97: break; + case 93: break; case 25: { return COMMA; } // fall through - case 98: break; + case 94: break; case 26: { return SEMI; } // fall through - case 99: break; + case 95: break; case 27: { return COLON; } // fall through - case 100: break; + case 96: break; case 28: { return EXP; } // fall through - case 101: break; + case 97: break; case 29: { return BIT_AND; } // fall through - case 102: break; + case 98: break; case 30: { return BIT_OR; } // fall through - case 103: break; + case 99: break; case 31: { yybegin(YYINITIAL); return STRING; } // fall through - case 104: break; + case 100: break; case 32: - { yypushback(yylength()); yybegin(xCOMMENT); - } - // fall through - case 105: break; - case 33: { return CONCAT; } // fall through - case 106: break; - case 34: + case 101: break; + case 33: { boolean block = checkBlock(); - if (block) { yypushback(yylength()); yybegin(xBLOCK_COMMENT); } + if (block) { + yypushback(yylength()); + zzMarkedPos += checkBlockEnd(); + return BLOCK_COMMENT; + } else { yypushback(yylength()); yybegin(xCOMMENT); } } // fall through - case 107: break; - case 35: + case 102: break; + case 34: { return IN; } // fall through - case 108: break; - case 36: + case 103: break; + case 35: { return IF; } // fall through - case 109: break; - case 37: + case 104: break; + case 36: { return OR; } // fall through - case 110: break; - case 38: + case 105: break; + case 37: { return DO; } // fall through - case 111: break; - case 39: - { yybegin(xBLOCK_STRING); yypushback(yylength()); checkBlock(); - } - // fall through - case 112: break; - case 40: + case 106: break; + case 38: { return EQ; } // fall through - case 113: break; - case 41: + case 107: break; + case 39: { yybegin(xSHEBANG); return SHEBANG; } // fall through - case 114: break; - case 42: + case 108: break; + case 40: { return GE; } // fall through - case 115: break; - case 43: + case 109: break; + case 41: { return BIT_RTRT; } // fall through - case 116: break; - case 44: + case 110: break; + case 42: { return LE; } // fall through - case 117: break; - case 45: + case 111: break; + case 43: { return BIT_LTLT; } // fall through - case 118: break; - case 46: + case 112: break; + case 44: { return NE; } // fall through - case 119: break; - case 47: + case 113: break; + case 45: { return DOUBLE_DIV; } // fall through - case 120: break; - case 48: + case 114: break; + case 46: { return DOUBLE_COLON; } // fall through - case 121: break; - case 49: + case 115: break; + case 47: { yybegin(YYINITIAL);return SHORT_COMMENT; } // fall through - case 122: break; - case 50: + case 116: break; + case 48: { return ELLIPSIS; } // fall through - case 123: break; - case 51: + case 117: break; + case 49: { return END; } // fall through - case 124: break; - case 52: + case 118: break; + case 50: { return NIL; } // fall through - case 125: break; - case 53: + case 119: break; + case 51: { return NOT; } // fall through - case 126: break; - case 54: + case 120: break; + case 52: { return AND; } // fall through - case 127: break; - case 55: + case 121: break; + case 53: { return FOR; } // fall through - case 128: break; - case 56: + case 122: break; + case 54: { yybegin(YYINITIAL);return DOC_COMMENT; } // fall through - case 129: break; - case 57: + case 123: break; + case 55: { return ELSE; } // fall through - case 130: break; - case 58: + case 124: break; + case 56: { if (level.getVersion() < LuaLanguageLevel.LUA52.getVersion()) return ID; else return GOTO; } // fall through - case 131: break; - case 59: + case 125: break; + case 57: { return TRUE; } // fall through - case 132: break; - case 60: + case 126: break; + case 58: { return THEN; } // fall through - case 133: break; - case 61: - { int redundant = checkBlockRedundant(); - if (redundant != -1) { - yypushback(redundant); - yybegin(YYINITIAL); return STRING; - } else { - yybegin(YYINITIAL); return TokenType.BAD_CHARACTER; - } - } - // fall through - case 134: break; - case 62: - { int redundant = checkBlockRedundant(); - if (redundant != -1) { - yypushback(redundant); - yybegin(YYINITIAL);return BLOCK_COMMENT; } - else { yybegin(YYINITIAL);return BLOCK_COMMENT; } - } - // fall through - case 135: break; - case 63: + case 127: break; + case 59: { return REGION; } // fall through - case 136: break; - case 64: + case 128: break; + case 60: { return ENDREGION; } // fall through - case 137: break; - case 65: + case 129: break; + case 61: { return BREAK; } // fall through - case 138: break; - case 66: + case 130: break; + case 62: { return LOCAL; } // fall through - case 139: break; - case 67: + case 131: break; + case 63: { return FALSE; } // fall through - case 140: break; - case 68: + case 132: break; + case 64: { return UNTIL; } // fall through - case 141: break; - case 69: + case 133: break; + case 65: { return WHILE; } // fall through - case 142: break; - case 70: + case 134: break; + case 66: { return RETURN; } // fall through - case 143: break; - case 71: + case 135: break; + case 67: { return REPEAT; } // fall through - case 144: break; - case 72: + case 136: break; + case 68: { return ELSEIF; } // fall through - case 145: break; - case 73: + case 137: break; + case 69: { return FUNCTION; } // fall through - case 146: break; + case 138: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/EmmyLua-Common/src/main/java/com/tang/intellij/lua/lua.flex b/EmmyLua-Common/src/main/java/com/tang/intellij/lua/lua.flex index 6f2a6527..f1221a63 100644 --- a/EmmyLua-Common/src/main/java/com/tang/intellij/lua/lua.flex +++ b/EmmyLua-Common/src/main/java/com/tang/intellij/lua/lua.flex @@ -36,16 +36,27 @@ import static com.tang.intellij.lua.psi.LuaTypes.*; return false; } - private int checkBlockRedundant() { - int redundant = -1; - String cs = yytext().toString(); - StringBuilder s = new StringBuilder("]"); - for (int i = 0; i < nBrackets; i++) s.append('='); - s.append(']'); - int index = cs.indexOf(s.toString()); - if (index > 0) - redundant = yylength() - index - nBrackets - 2; - return redundant; + private int checkBlockEnd() { + int pos = zzMarkedPos; + int end = zzEndRead; + while(pos < end) { + char c = zzBuffer.charAt(pos); + if (c == ']') { + pos++; + int size = 0; + while (pos < zzEndRead && zzBuffer.charAt(pos) == '=') { + size++; + pos++; + } + if (size == nBrackets && zzBuffer.charAt(pos) == ']') { + pos++; + break; + } + continue; + } + pos++; + } + return pos - zzMarkedPos; } %} @@ -101,7 +112,11 @@ LONG_STRING=\[=*\[[\s\S]*\]=*\] {REGION_END} { return ENDREGION; } "--" { boolean block = checkBlock(); - if (block) { yypushback(yylength()); yybegin(xBLOCK_COMMENT); } + if (block) { + yypushback(yylength()); + zzMarkedPos += checkBlockEnd(); + return BLOCK_COMMENT; + } else { yypushback(yylength()); yybegin(xCOMMENT); } } "and" { return AND; } @@ -147,7 +162,16 @@ LONG_STRING=\[=*\[[\s\S]*\]=*\] "<" { return LT; } "(" { return LPAREN; } ")" { return RPAREN; } - "[" { return LBRACK; } + "[" { + if (checkAhead('=', 0) || checkAhead('[', 0)) { + yypushback(yylength()); + checkBlock(); + zzMarkedPos += checkBlockEnd(); + return STRING; + } else { + return LBRACK; + } + } "]" { return RBRACK; } "{" { return LCURLY; } "}" { return RCURLY; } @@ -164,7 +188,6 @@ LONG_STRING=\[=*\[[\s\S]*\]=*\] "\"" { yybegin(xDOUBLE_QUOTED_STRING); yypushback(yylength()); } "'" { yybegin(xSINGLE_QUOTED_STRING); yypushback(yylength()); } - \[=*\[ { yybegin(xBLOCK_STRING); yypushback(yylength()); checkBlock(); } {ID} { return ID; } {NUMBER} { return NUMBER; } @@ -181,34 +204,10 @@ LONG_STRING=\[=*\[[\s\S]*\]=*\] {SHORT_COMMENT} {yybegin(YYINITIAL);return SHORT_COMMENT;} } -<xBLOCK_COMMENT> { - {BLOCK_COMMENT} { - int redundant = checkBlockRedundant(); - if (redundant != -1) { - yypushback(redundant); - yybegin(YYINITIAL);return BLOCK_COMMENT; } - else { yybegin(YYINITIAL);return BLOCK_COMMENT; } - } - [^] { yypushback(yylength()); yybegin(xCOMMENT); } -} - <xDOUBLE_QUOTED_STRING> { {DOUBLE_QUOTED_STRING} { yybegin(YYINITIAL); return STRING; } } <xSINGLE_QUOTED_STRING> { {SINGLE_QUOTED_STRING} { yybegin(YYINITIAL); return STRING; } -} - -<xBLOCK_STRING> { - {LONG_STRING} { - int redundant = checkBlockRedundant(); - if (redundant != -1) { - yypushback(redundant); - yybegin(YYINITIAL); return STRING; - } else { - yybegin(YYINITIAL); return TokenType.BAD_CHARACTER; - } - } - [^] { return TokenType.BAD_CHARACTER; } } \ No newline at end of file