From bc13ff664d80a214065439ba29b82df58de8a210 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 27 Jan 2010 18:42:15 +0300 Subject: [PATCH] long string parsing fixed again --- .../com/jetbrains/python/lexer/Python.flex | 13 +- .../jetbrains/python/lexer/_PythonLexer.java | 389 +++++++++--------- python/testData/psi/LongString.py | 5 + python/testData/psi/LongString.txt | 46 +++ .../com/jetbrains/python/PythonLexerTest.java | 4 + .../jetbrains/python/PythonParsingTest.java | 4 + 6 files changed, 245 insertions(+), 216 deletions(-) create mode 100644 python/testData/psi/LongString.py create mode 100644 python/testData/psi/LongString.txt diff --git a/python/src/com/jetbrains/python/lexer/Python.flex b/python/src/com/jetbrains/python/lexer/Python.flex index 3b8a881dfa79..b4adc4afe6f9 100644 --- a/python/src/com/jetbrains/python/lexer/Python.flex +++ b/python/src/com/jetbrains/python/lexer/Python.flex @@ -50,20 +50,11 @@ QUOTED_LITERAL="'"([^\\\'\r\n]|{ESCAPE_SEQUENCE}|(\\[\r\n]))*("'"|\\)? DOUBLE_QUOTED_LITERAL=\"([^\\\"\r\n]|{ESCAPE_SEQUENCE}|(\\[\r\n]))*?(\"|\\)? ESCAPE_SEQUENCE=\\[^\r\n] -/* -TRIPLE_QUOTED_LITERAL="\"\"\""~([^\\]"\"\"\"") -TRIPLE_APOS_LITERAL="\'\'\'"~([^\\]"\'\'\'") -*/ THREE_QUO = (\"\"\") -ESCAPED_CHAR = (\\[^] | [^\\]) -NONQUO_CHAR = (\\[^] | [^i\\\"]) -STRING_3CHAR_QUO = ({ESCAPED_CHAR}{1,2}? {NONQUO_CHAR}) -TRIPLE_QUOTED_LITERAL = {THREE_QUO} {STRING_3CHAR_QUO}* {THREE_QUO} +TRIPLE_QUOTED_LITERAL = {THREE_QUO} ~ {THREE_QUO} THREE_APOS = (\'\'\') -NONAPOS_CHAR = (\\[^] | [^i\\\']) -STRING_3CHAR_APOS = ({ESCAPED_CHAR}{1,2}? {NONAPOS_CHAR}) -TRIPLE_APOS_LITERAL = {THREE_APOS} {STRING_3CHAR_APOS}* {THREE_APOS} +TRIPLE_APOS_LITERAL = {THREE_APOS} ~ {THREE_APOS} %% diff --git a/python/src/com/jetbrains/python/lexer/_PythonLexer.java b/python/src/com/jetbrains/python/lexer/_PythonLexer.java index e576dceea979..206b4a6854fc 100644 --- a/python/src/com/jetbrains/python/lexer/_PythonLexer.java +++ b/python/src/com/jetbrains/python/lexer/_PythonLexer.java @@ -1,4 +1,4 @@ -/* The following code was generated by JFlex 1.4.3 on 26.01.10 16:53 */ +/* The following code was generated by JFlex 1.4.3 on 27.01.10 18:41 */ /* It's an automatically generated code. Do not modify it. */ package com.jetbrains.python.lexer; @@ -11,7 +11,7 @@ import com.jetbrains.python.PyTokenTypes; /** * This class is a scanner generated by * JFlex 1.4.3 - * on 26.01.10 16:53 from the specification file + * on 27.01.10 18:41 from the specification file * C:/JetBrains/IDEA/tools/lexer/../../python/src/com/jetbrains/python/lexer/Python.flex */ class _PythonLexer implements FlexLexer { @@ -35,14 +35,14 @@ class _PythonLexer implements FlexLexer { * Translates characters to character classes */ private static final String ZZ_CMAP_PACKED = - "\11\0\1\41\1\13\1\0\1\42\1\13\22\0\1\40\1\72\1\36"+ + "\11\0\1\40\1\13\1\0\1\41\1\13\22\0\1\37\1\72\1\36"+ "\1\12\1\0\1\64\1\65\1\34\1\74\1\75\1\62\1\60\1\103"+ "\1\26\1\23\1\63\1\1\1\5\6\3\2\2\1\104\1\106\1\71"+ "\1\61\1\70\1\0\1\102\1\15\1\20\2\15\1\25\1\15\3\14"+ "\1\27\1\14\1\21\2\14\1\17\2\14\1\32\2\14\1\30\2\14"+ - "\1\16\2\14\1\76\1\35\1\77\1\67\1\14\1\105\1\43\1\10"+ - "\1\51\1\45\1\24\1\4\1\55\1\57\1\37\1\27\1\50\1\11"+ - "\1\54\1\44\1\7\1\52\1\14\1\33\1\46\1\47\1\31\1\14"+ + "\1\16\2\14\1\76\1\35\1\77\1\67\1\14\1\105\1\42\1\10"+ + "\1\50\1\44\1\24\1\4\1\55\1\57\1\51\1\27\1\47\1\11"+ + "\1\54\1\43\1\7\1\52\1\14\1\33\1\45\1\46\1\31\1\14"+ "\1\56\1\6\1\53\1\14\1\100\1\66\1\101\1\73\53\0\1\14"+ "\12\0\1\14\4\0\1\14\5\0\27\14\1\0\7\14\30\14\1\0"+ "\10\14\1\14\1\14\1\14\1\14\1\14\1\14\1\14\1\14\1\14"+ @@ -215,24 +215,24 @@ class _PythonLexer implements FlexLexer { private static final String ZZ_ACTION_PACKED_0 = "\1\0\1\1\2\2\5\3\1\4\1\5\1\3\1\6"+ - "\1\3\1\7\2\3\1\10\1\11\1\10\1\3\1\12"+ - "\1\13\1\14\11\3\1\15\1\16\1\17\1\20\1\21"+ - "\1\22\1\23\1\24\1\25\1\26\1\1\1\27\1\30"+ - "\1\31\1\32\1\33\1\34\1\35\1\36\1\37\1\40"+ - "\1\41\1\42\1\2\4\0\1\2\1\43\1\0\1\44"+ - "\3\3\1\45\4\3\1\46\2\3\6\10\1\47\1\50"+ - "\1\51\14\3\1\52\1\53\1\54\1\55\1\56\1\57"+ + "\1\3\1\7\2\3\1\10\1\11\1\10\1\12\1\13"+ + "\1\14\12\3\1\15\1\16\1\17\1\20\1\21\1\22"+ + "\1\23\1\24\1\25\1\26\1\1\1\27\1\30\1\31"+ + "\1\32\1\33\1\34\1\35\1\36\1\37\1\40\1\41"+ + "\1\42\1\2\4\0\1\2\1\43\1\0\1\44\3\3"+ + "\1\45\4\3\1\46\2\3\6\10\7\3\1\47\1\50"+ + "\1\51\5\3\1\52\1\53\1\54\1\55\1\56\1\57"+ "\1\60\1\61\1\62\1\63\1\64\1\65\1\66\1\67"+ "\1\70\1\71\3\2\1\43\1\0\1\72\11\3\1\10"+ - "\2\0\1\3\1\73\1\3\1\74\1\75\1\76\1\77"+ - "\6\3\1\100\1\101\1\102\1\103\1\104\4\3\1\105"+ - "\1\106\2\3\6\0\4\3\1\107\4\3\1\110\3\3"+ - "\1\111\4\0\3\3\1\112\1\113\1\3\1\114\1\3"+ - "\1\115\1\116\1\117\1\120\1\121\1\3\1\122\1\123"+ - "\1\3\1\124"; + "\2\0\1\73\1\3\1\74\1\75\1\76\1\77\7\3"+ + "\1\100\1\101\1\102\1\103\1\104\4\3\1\105\1\106"+ + "\2\3\2\0\4\3\1\107\4\3\1\110\3\3\1\111"+ + "\2\0\2\3\1\112\1\3\1\113\1\3\1\114\1\3"+ + "\1\115\1\116\1\117\2\10\1\120\1\3\1\121\1\122"+ + "\1\123\2\10\1\3\1\124"; private static int [] zzUnpackAction() { - int [] result = new int[199]; + int [] result = new int[197]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -259,7 +259,7 @@ class _PythonLexer implements FlexLexer { private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\107\0\216\0\325\0\u011c\0\u0163\0\u01aa\0\u01f1"+ "\0\u0238\0\u027f\0\u02c6\0\u030d\0\u0354\0\u039b\0\u03e2\0\u0429"+ - "\0\u0470\0\u04b7\0\107\0\u04fe\0\u0545\0\107\0\107\0\107"+ + "\0\u0470\0\u04b7\0\107\0\u04fe\0\107\0\107\0\107\0\u0545"+ "\0\u058c\0\u05d3\0\u061a\0\u0661\0\u06a8\0\u06ef\0\u0736\0\u077d"+ "\0\u07c4\0\u080b\0\u0852\0\u0899\0\u08e0\0\u0927\0\u096e\0\u09b5"+ "\0\u09fc\0\u0a43\0\u0a8a\0\u0ad1\0\107\0\107\0\107\0\107"+ @@ -267,24 +267,24 @@ class _PythonLexer implements FlexLexer { "\0\u0b18\0\u0b5f\0\u0ba6\0\u0bed\0\u0c34\0\107\0\u0c7b\0\u0cc2"+ "\0\107\0\u0d09\0\u0d50\0\u0d97\0\u0163\0\u0dde\0\u0e25\0\u0e6c"+ "\0\u0eb3\0\107\0\u0efa\0\u0f41\0\u0f88\0\u0fcf\0\u1016\0\u105d"+ - "\0\u10a4\0\u10eb\0\u0163\0\u0163\0\u0163\0\u1132\0\u1179\0\u11c0"+ - "\0\u1207\0\u124e\0\u1295\0\u12dc\0\u1323\0\u136a\0\u13b1\0\u13f8"+ + "\0\u10a4\0\u10eb\0\u1132\0\u1179\0\u11c0\0\u1207\0\u124e\0\u1295"+ + "\0\u12dc\0\u0163\0\u0163\0\u0163\0\u1323\0\u136a\0\u13b1\0\u13f8"+ "\0\u143f\0\107\0\107\0\107\0\u1486\0\107\0\u14cd\0\107"+ "\0\107\0\107\0\107\0\107\0\u1514\0\107\0\107\0\u155b"+ "\0\107\0\u15a2\0\u15e9\0\u1630\0\u1677\0\u16be\0\u0163\0\u1705"+ "\0\u174c\0\u1793\0\u17da\0\u1821\0\u1868\0\u18af\0\u18f6\0\u193d"+ - "\0\107\0\u1984\0\u19cb\0\u1a12\0\u0163\0\u1a59\0\u0163\0\u0163"+ - "\0\u0163\0\u0163\0\u1aa0\0\u1ae7\0\u1b2e\0\u1b75\0\u1bbc\0\u1c03"+ + "\0\107\0\u1984\0\u19cb\0\u0163\0\u1a12\0\u0163\0\u0163\0\u0163"+ + "\0\u0163\0\u1a59\0\u1aa0\0\u1ae7\0\u1b2e\0\u1b75\0\u1bbc\0\u1c03"+ "\0\107\0\107\0\107\0\107\0\u0163\0\u1c4a\0\u1c91\0\u1cd8"+ "\0\u1d1f\0\u0163\0\u0163\0\u1d66\0\u1dad\0\u1df4\0\u1e3b\0\u1e82"+ - "\0\u1ec9\0\u1f10\0\u1f57\0\u1f9e\0\u1fe5\0\u202c\0\u2073\0\u0163"+ - "\0\u20ba\0\u2101\0\u2148\0\u218f\0\u0163\0\u21d6\0\u221d\0\u2264"+ - "\0\u0163\0\u22ab\0\u22f2\0\u2339\0\u2380\0\u23c7\0\u240e\0\u2455"+ - "\0\u0163\0\u0163\0\u249c\0\u0163\0\u24e3\0\u0163\0\u0163\0\u0163"+ - "\0\u0163\0\u0163\0\u252a\0\u0163\0\u0163\0\u2571\0\u0163"; + "\0\u1ec9\0\u1f10\0\u1f57\0\u0163\0\u1f9e\0\u1fe5\0\u202c\0\u2073"+ + "\0\u0163\0\u20ba\0\u2101\0\u2148\0\u0163\0\u218f\0\u21d6\0\u221d"+ + "\0\u2264\0\u0163\0\u22ab\0\u0163\0\u22f2\0\u0163\0\u2339\0\u0163"+ + "\0\u0163\0\u0163\0\u2380\0\u23c7\0\u0163\0\u240e\0\u0163\0\u0163"+ + "\0\u0163\0\u2455\0\u249c\0\u24e3\0\u0163"; private static int [] zzUnpackRowMap() { - int [] result = new int[199]; + int [] result = new int[197]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -311,7 +311,7 @@ class _PythonLexer implements FlexLexer { "\1\11\1\12\1\13\4\6\1\14\1\6\1\2\1\15"+ "\1\16\1\6\1\17\1\6\2\14\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\6\1\34\1\6\1\35\1\36\1\37\1\6"+ + "\1\6\1\33\1\6\1\34\1\35\1\36\1\37\1\6"+ "\1\40\1\41\1\6\1\42\1\43\1\44\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\63\1\64\1\65\1\66"+ @@ -320,179 +320,158 @@ class _PythonLexer implements FlexLexer { "\1\76\1\0\1\77\2\100\1\0\1\101\60\0\3\4"+ "\1\0\1\4\3\0\1\76\7\0\1\76\1\0\1\77"+ "\2\100\1\0\1\101\60\0\6\6\1\102\2\6\2\0"+ - "\7\6\1\0\2\6\1\0\4\6\1\103\3\0\1\104"+ - "\3\0\15\6\30\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\4\6\1\105\3\0"+ - "\1\6\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\3\6\1\20\1\106\1\22\1\0\1\24"+ - "\1\6\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\1\107\14\6"+ - "\27\0\13\12\1\0\73\12\13\0\1\13\74\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\3\6\2\20\1\22"+ - "\1\0\1\24\1\6\3\0\15\6\30\0\3\77\1\0"+ + "\7\6\1\0\2\6\1\0\4\6\1\103\6\0\7\6"+ + "\1\104\6\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\16\6\30\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\4\6\1\105\6\0\16\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\3\6\1\20"+ + "\1\106\1\22\1\0\1\24\3\0\16\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\1\107"+ + "\15\6\27\0\13\12\1\0\73\12\13\0\1\13\74\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\3\6\2\20"+ + "\1\22\1\0\1\24\3\0\16\6\30\0\3\77\1\0"+ "\1\77\102\0\5\6\1\110\2\6\1\111\2\0\7\6"+ - "\1\0\2\6\1\0\5\6\3\0\1\6\3\0\15\6"+ - "\110\0\1\112\26\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\1\22\1\0\1\24\1\6\3\0\15\6"+ - "\30\0\11\6\2\0\7\6\1\0\1\113\1\6\1\0"+ - "\5\6\1\22\1\0\1\24\1\6\3\0\1\114\14\6"+ - "\27\0\13\115\1\0\20\115\1\116\1\117\51\115\13\120"+ - "\1\0\21\120\1\121\1\122\50\120\1\0\3\6\1\123"+ - "\5\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\1\6\1\124\1\6\1\125\5\6\1\126"+ - "\3\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\1\6\1\127\1\6\1\130"+ - "\11\6\30\0\6\6\1\131\2\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\15\6\30\0"+ - "\11\6\2\0\7\6\1\0\1\132\1\6\1\0\5\6"+ - "\3\0\1\6\3\0\15\6\30\0\11\6\2\0\7\6"+ - "\1\0\2\6\1\0\4\6\1\133\3\0\1\6\3\0"+ - "\15\6\30\0\6\6\1\134\1\6\1\135\2\0\7\6"+ - "\1\0\2\6\1\0\5\6\3\0\1\6\3\0\15\6"+ + "\1\0\2\6\1\0\5\6\6\0\16\6\110\0\1\112"+ + "\26\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\1\22\1\0\1\24\3\0\16\6\30\0\11\6\2\0"+ + "\7\6\1\0\1\113\1\6\1\0\5\6\1\22\1\0"+ + "\1\24\3\0\1\114\15\6\27\0\13\115\1\0\20\115"+ + "\1\116\1\117\51\115\13\120\1\0\21\120\1\121\1\122"+ + "\50\120\1\0\11\6\2\0\7\6\1\0\2\6\1\0"+ + "\5\6\6\0\1\6\1\123\1\6\1\124\12\6\30\0"+ + "\6\6\1\125\2\6\2\0\7\6\1\0\2\6\1\0"+ + "\5\6\6\0\16\6\30\0\11\6\2\0\7\6\1\0"+ + "\1\126\1\6\1\0\5\6\6\0\16\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\4\6\1\127\6\0"+ + "\16\6\30\0\6\6\1\130\1\6\1\131\2\0\7\6"+ + "\1\0\2\6\1\0\5\6\6\0\16\6\30\0\3\6"+ + "\1\132\5\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\1\6\1\133\1\6\1\134\6\6\1\135\3\6"+ "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ - "\3\0\1\6\3\0\1\136\14\6\30\0\11\6\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\137\3\0"+ - "\15\6\30\0\10\6\1\140\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\5\6\3\0\1\6"+ - "\3\0\14\6\1\141\110\0\1\142\106\0\1\143\106\0"+ - "\1\144\1\145\105\0\1\146\1\0\1\147\104\0\1\150"+ - "\106\0\1\151\106\0\1\152\106\0\1\153\106\0\1\154"+ - "\6\0\1\155\77\0\1\156\6\0\1\157\1\160\76\0"+ - "\1\161\26\0\1\71\1\72\1\71\1\0\1\71\3\0"+ - "\1\76\7\0\1\76\1\0\1\77\2\100\1\0\1\101"+ - "\60\0\3\72\1\0\1\72\15\0\1\77\2\100\1\0"+ - "\1\101\60\0\5\162\2\0\1\162\4\0\1\162\2\0"+ - "\1\162\3\0\2\162\15\0\1\162\1\0\1\162\3\0"+ - "\1\162\36\0\1\163\1\0\1\163\1\0\1\163\102\0"+ - "\1\164\3\0\1\164\102\0\3\77\1\0\1\77\16\0"+ - "\2\100\1\0\1\101\60\0\3\165\1\0\1\165\20\0"+ - "\1\166\31\0\1\166\27\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\4\6\1\167\3\0\1\6\3\0\15\6"+ + "\6\0\1\136\15\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\7\6\1\137\6\6\30\0"+ + "\10\6\1\140\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\16\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\15\6\1\141\110\0\1\142\106\0"+ + "\1\143\106\0\1\144\1\145\105\0\1\146\1\0\1\147"+ + "\104\0\1\150\106\0\1\151\106\0\1\152\106\0\1\153"+ + "\106\0\1\154\6\0\1\155\77\0\1\156\6\0\1\157"+ + "\1\160\76\0\1\161\26\0\1\71\1\72\1\71\1\0"+ + "\1\71\3\0\1\76\7\0\1\76\1\0\1\77\2\100"+ + "\1\0\1\101\60\0\3\72\1\0\1\72\15\0\1\77"+ + "\2\100\1\0\1\101\60\0\5\162\2\0\1\162\4\0"+ + "\1\162\2\0\1\162\3\0\2\162\14\0\1\162\1\0"+ + "\1\162\3\0\1\162\37\0\1\163\1\0\1\163\1\0"+ + "\1\163\102\0\1\164\3\0\1\164\102\0\3\77\1\0"+ + "\1\77\16\0\2\100\1\0\1\101\60\0\3\165\1\0"+ + "\1\165\20\0\1\166\31\0\1\166\27\0\11\6\2\0"+ + "\7\6\1\0\2\6\1\0\4\6\1\167\6\0\16\6"+ "\30\0\6\6\1\170\2\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\5\6\3\0\1\6"+ - "\3\0\1\6\1\171\13\6\30\0\11\6\2\0\7\6"+ - "\1\0\1\172\1\6\1\0\5\6\1\22\1\0\1\24"+ - "\1\6\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\11\6\1\173"+ - "\3\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\6\6\1\174\6\6\30\0"+ - "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\175\3\0\3\6\1\176\11\6\30\0\11\6\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\6\3\0"+ - "\4\6\1\177\10\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\200\3\0\15\6\27\0"+ - "\13\115\1\0\20\115\1\201\1\117\51\115\34\0\1\202"+ - "\52\0\107\115\13\120\1\0\21\120\1\121\1\201\157\120"+ - "\36\0\1\203\51\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\7\6\1\204\5\6"+ + "\1\0\5\6\6\0\16\6\30\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\5\6\6\0\1\6\1\171\14\6"+ + "\30\0\11\6\2\0\7\6\1\0\1\172\1\6\1\0"+ + "\5\6\1\22\1\0\1\24\3\0\16\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\12\6"+ + "\1\173\3\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\6\6\1\174\7\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\3\6"+ + "\1\175\3\6\1\176\6\6\30\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\5\6\6\0\4\6\1\177\11\6"+ "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ - "\3\0\1\6\3\0\2\6\1\205\12\6\30\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\5\6\3\0\1\6"+ - "\3\0\3\6\1\206\11\6\30\0\11\6\2\0\7\6"+ - "\1\0\2\6\1\0\5\6\3\0\1\6\3\0\4\6"+ - "\1\207\10\6\30\0\3\6\1\210\4\6\1\211\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\6\3\0"+ - "\15\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\10\6\1\212\4\6\30\0"+ - "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\1\6\1\213\13\6\30\0\11\6\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\6\3\0"+ - "\1\214\14\6\30\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\3\6\1\215\11\6"+ - "\30\0\11\6\2\0\7\6\1\0\1\216\1\6\1\0"+ - "\5\6\3\0\1\6\3\0\15\6\30\0\6\6\1\217"+ - "\2\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\220\3\0\15\6\110\0"+ - "\1\221\106\0\1\222\106\0\1\223\106\0\1\224\26\0"+ - "\5\162\2\0\1\162\1\76\3\0\1\162\2\0\1\162"+ - "\1\76\2\0\2\162\15\0\1\162\1\0\1\162\3\0"+ - "\1\162\36\0\1\163\1\0\1\163\1\0\1\163\3\0"+ - "\1\76\7\0\1\76\66\0\1\164\3\0\1\164\3\0"+ - "\1\76\7\0\1\76\66\0\3\165\1\0\1\165\21\0"+ - "\1\101\60\0\3\165\1\0\1\165\102\0\11\6\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\6\3\0"+ - "\11\6\1\225\3\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\1\226\14\6"+ + "\6\0\7\6\1\200\6\6\27\0\13\115\1\0\20\115"+ + "\1\201\1\117\51\115\34\0\1\202\52\0\107\115\13\120"+ + "\1\0\21\120\1\121\1\201\157\120\36\0\1\203\51\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\2\6\1\204\13\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\3\6\1\205\12\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\4\6\1\206\11\6\30\0\3\6\1\207\4\6\1\210"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\16\6"+ "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ - "\3\0\1\6\3\0\1\227\14\6\30\0\7\6\1\230"+ - "\1\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\1\231\1\6\1\0\5\6\3\0\1\6\3\0\15\6"+ - "\30\0\3\6\1\232\5\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\1\233\1\6\1\0\5\6\3\0"+ - "\1\6\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\2\6\1\234\2\6\3\0\1\6\3\0"+ - "\15\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\3\6\1\235\11\6\27\0"+ - "\34\202\1\236\1\237\1\202\1\240\47\202\35\203\1\241"+ - "\1\242\1\243\47\203\1\0\6\6\1\244\2\6\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\6\3\0"+ - "\15\6\30\0\11\6\2\0\7\6\1\0\1\245\1\6"+ - "\1\0\5\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\5\6\3\0\1\6"+ - "\3\0\4\6\1\246\10\6\30\0\11\6\2\0\7\6"+ - "\1\0\2\6\1\0\5\6\3\0\1\6\3\0\3\6"+ - "\1\247\11\6\30\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\3\6\1\250\11\6"+ - "\30\0\10\6\1\251\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\15\6\30\0\7\6\1\252"+ - "\1\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\15\6\30\0\10\6\1\253\2\0\7\6"+ - "\1\0\2\6\1\0\5\6\3\0\1\6\3\0\15\6"+ - "\30\0\10\6\1\254\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\15\6\30\0\11\6\2\0"+ - "\7\6\1\0\2\6\1\0\5\6\3\0\1\6\3\0"+ - "\5\6\1\255\7\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\2\6\1\256"+ - "\12\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\7\6\1\257\5\6\30\0"+ - "\11\6\2\0\7\6\1\0\2\6\1\0\4\6\1\260"+ - "\3\0\1\6\3\0\15\6\30\0\11\6\2\0\7\6"+ - "\1\0\1\261\1\6\1\0\5\6\3\0\1\6\3\0"+ - "\15\6\27\0\34\202\1\262\1\237\1\202\1\263\212\202"+ - "\1\263\1\237\1\202\1\263\47\202\144\203\1\241\1\264"+ - "\1\265\104\203\1\241\2\265\47\203\1\0\11\6\2\0"+ - "\7\6\1\0\2\6\1\0\4\6\1\266\3\0\1\6"+ - "\3\0\15\6\30\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\4\6\1\267\3\0\1\6\3\0\15\6\30\0"+ - "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\270\3\0\15\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\3\6\1\271"+ - "\11\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\2\6\1\272\12\6\30\0"+ - "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\1\273\14\6\30\0\11\6\2\0\7\6"+ - "\1\0\1\274\1\6\1\0\5\6\3\0\1\6\3\0"+ - "\15\6\30\0\10\6\1\275\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\2\6\1\0\5\6\3\0\1\6"+ - "\3\0\1\276\14\6\30\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\4\6\1\277"+ - "\10\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\1\6\1\300\13\6\27\0"+ - "\34\202\1\201\1\237\1\202\1\0\103\202\1\0\1\237"+ - "\1\202\1\0\47\202\35\203\1\241\1\201\1\0\104\203"+ - "\1\241\2\0\47\203\1\0\11\6\2\0\7\6\1\0"+ - "\2\6\1\0\5\6\3\0\1\6\3\0\4\6\1\301"+ - "\10\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ - "\5\6\3\0\1\6\3\0\4\6\1\302\10\6\30\0"+ - "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\3\0"+ - "\1\6\3\0\1\6\1\303\13\6\30\0\10\6\1\304"+ - "\2\0\7\6\1\0\2\6\1\0\5\6\3\0\1\6"+ - "\3\0\15\6\30\0\11\6\2\0\7\6\1\0\2\6"+ - "\1\0\5\6\3\0\1\6\3\0\10\6\1\305\4\6"+ - "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\2\6"+ - "\1\306\2\6\3\0\1\6\3\0\15\6\30\0\11\6"+ - "\2\0\7\6\1\0\1\307\1\6\1\0\5\6\3\0"+ - "\1\6\3\0\15\6\27\0"; + "\6\0\11\6\1\211\4\6\30\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\5\6\6\0\1\6\1\212\14\6"+ + "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\1\213\15\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\10\6\1\214\5\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\3\6\1\215\12\6\30\0\11\6\2\0\7\6\1\0"+ + "\1\216\1\6\1\0\5\6\6\0\16\6\30\0\6\6"+ + "\1\217\2\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\16\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\7\6\1\220\6\6\110\0\1\221"+ + "\106\0\1\222\106\0\1\223\106\0\1\224\26\0\5\162"+ + "\2\0\1\162\1\76\3\0\1\162\2\0\1\162\1\76"+ + "\2\0\2\162\14\0\1\162\1\0\1\162\3\0\1\162"+ + "\37\0\1\163\1\0\1\163\1\0\1\163\3\0\1\76"+ + "\7\0\1\76\66\0\1\164\3\0\1\164\3\0\1\76"+ + "\7\0\1\76\66\0\3\165\1\0\1\165\21\0\1\101"+ + "\60\0\3\165\1\0\1\165\102\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\5\6\6\0\12\6\1\225\3\6"+ + "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\1\226\15\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\1\227\15\6\30\0\7\6"+ + "\1\230\1\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\16\6\30\0\11\6\2\0\7\6\1\0\1\231"+ + "\1\6\1\0\5\6\6\0\16\6\30\0\11\6\2\0"+ + "\7\6\1\0\1\232\1\6\1\0\5\6\6\0\16\6"+ + "\30\0\3\6\1\233\5\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\16\6\30\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\2\6\1\234\2\6\6\0\16\6"+ + "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\3\6\1\235\12\6\27\0\34\202\1\236\52\202"+ + "\36\203\1\237\50\203\1\0\11\6\2\0\7\6\1\0"+ + "\1\240\1\6\1\0\5\6\6\0\16\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\4\6"+ + "\1\241\11\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\3\6\1\242\12\6\30\0\6\6"+ + "\1\243\2\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\16\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\3\6\1\244\12\6\30\0\10\6"+ + "\1\245\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\16\6\30\0\7\6\1\246\1\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\16\6\30\0\10\6\1\247"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\16\6"+ + "\30\0\10\6\1\250\2\0\7\6\1\0\2\6\1\0"+ + "\5\6\6\0\16\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\5\6\1\251\10\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\2\6\1\252\13\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\10\6\1\253\5\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\4\6\1\254"+ + "\6\0\16\6\30\0\11\6\2\0\7\6\1\0\1\255"+ + "\1\6\1\0\5\6\6\0\16\6\27\0\34\202\1\256"+ + "\52\202\36\203\1\257\50\203\1\0\11\6\2\0\7\6"+ + "\1\0\2\6\1\0\4\6\1\260\6\0\16\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\7\6\1\261\6\6\30\0\11\6\2\0\7\6\1\0"+ + "\2\6\1\0\5\6\6\0\3\6\1\262\12\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\4\6\1\263"+ + "\6\0\16\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\2\6\1\264\13\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\1\265"+ + "\15\6\30\0\11\6\2\0\7\6\1\0\1\266\1\6"+ + "\1\0\5\6\6\0\16\6\30\0\10\6\1\267\2\0"+ + "\7\6\1\0\2\6\1\0\5\6\6\0\16\6\30\0"+ + "\11\6\2\0\7\6\1\0\2\6\1\0\5\6\6\0"+ + "\1\270\15\6\30\0\11\6\2\0\7\6\1\0\2\6"+ + "\1\0\5\6\6\0\4\6\1\271\11\6\30\0\11\6"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\1\6"+ + "\1\272\14\6\27\0\34\202\1\273\52\202\36\203\1\274"+ + "\50\203\1\0\11\6\2\0\7\6\1\0\2\6\1\0"+ + "\5\6\6\0\4\6\1\275\11\6\30\0\11\6\2\0"+ + "\7\6\1\0\2\6\1\0\5\6\6\0\1\6\1\276"+ + "\14\6\30\0\11\6\2\0\7\6\1\0\2\6\1\0"+ + "\5\6\6\0\4\6\1\277\11\6\30\0\10\6\1\300"+ + "\2\0\7\6\1\0\2\6\1\0\5\6\6\0\16\6"+ + "\30\0\11\6\2\0\7\6\1\0\2\6\1\0\5\6"+ + "\6\0\11\6\1\301\4\6\63\0\1\302\110\0\1\303"+ + "\51\0\11\6\2\0\7\6\1\0\2\6\1\0\2\6"+ + "\1\304\2\6\6\0\16\6\63\0\1\201\110\0\1\201"+ + "\51\0\11\6\2\0\7\6\1\0\1\305\1\6\1\0"+ + "\5\6\6\0\16\6\27\0"; private static int [] zzUnpackTrans() { - int [] result = new int[9656]; + int [] result = new int[9514]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -533,14 +512,14 @@ class _PythonLexer implements FlexLexer { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\1\0\1\11\20\1\1\11\2\1\3\11\24\1\14\11"+ + "\1\0\1\11\20\1\1\11\1\1\3\11\25\1\14\11"+ "\1\1\4\0\1\11\1\1\1\0\1\11\10\1\1\11"+ "\27\1\3\11\1\1\1\11\1\1\5\11\1\1\2\11"+ "\1\1\1\11\4\1\1\0\12\1\1\11\2\0\15\1"+ - "\4\11\11\1\6\0\16\1\4\0\22\1"; + "\4\11\11\1\2\0\16\1\2\0\26\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[199]; + int [] result = new int[197]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -973,7 +952,7 @@ class _PythonLexer implements FlexLexer { { return PyTokenTypes.OR; } case 113: break; - case 70: + case 69: { return PyTokenTypes.ELSE_KEYWORD; } case 114: break; @@ -993,7 +972,7 @@ class _PythonLexer implements FlexLexer { { return PyTokenTypes.MULT; } case 118: break; - case 81: + case 80: { return PyTokenTypes.ASSERT_KEYWORD; } case 119: break; @@ -1101,7 +1080,7 @@ class _PythonLexer implements FlexLexer { { return PyTokenTypes.RETURN_KEYWORD; } case 145: break; - case 80: + case 81: { return PyTokenTypes.IMPORT_KEYWORD; } case 146: break; @@ -1157,7 +1136,7 @@ class _PythonLexer implements FlexLexer { { return PyTokenTypes.EXPEQ; } case 159: break; - case 69: + case 70: { return PyTokenTypes.ELIF_KEYWORD; } case 160: break; diff --git a/python/testData/psi/LongString.py b/python/testData/psi/LongString.py new file mode 100644 index 000000000000..63c14bd564f3 --- /dev/null +++ b/python/testData/psi/LongString.py @@ -0,0 +1,5 @@ +a = """""" +b = """ +"1.0" encoding="ascii"? +""" +str = re.sub(r"""\\\\""", r"""\""", str) diff --git a/python/testData/psi/LongString.txt b/python/testData/psi/LongString.txt new file mode 100644 index 000000000000..f1e19288b8dd --- /dev/null +++ b/python/testData/psi/LongString.txt @@ -0,0 +1,46 @@ +PyFile:LongString.py + PyAssignmentStatement + PyTargetExpression: a + PsiElement(Py:IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiElement(Py:EQ)('=') + PsiWhiteSpace(' ') + PyStringLiteralExpression: + PsiElement(Py:STRING_LITERAL)('""""""') + PsiWhiteSpace('\n') + PyAssignmentStatement + PyTargetExpression: b + PsiElement(Py:IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiElement(Py:EQ)('=') + PsiWhiteSpace(' ') + PyStringLiteralExpression: +"1.0" encoding="ascii"? + + PsiElement(Py:STRING_LITERAL)('"""\n"1.0" encoding="ascii"?\n"""') + PsiWhiteSpace('\n') + PyAssignmentStatement + PyTargetExpression: str + PsiElement(Py:IDENTIFIER)('str') + PsiWhiteSpace(' ') + PsiElement(Py:EQ)('=') + PsiWhiteSpace(' ') + PyCallExpression: re.sub + PyReferenceExpression: sub + PyReferenceExpression: re + PsiElement(Py:IDENTIFIER)('re') + PsiElement(Py:DOT)('.') + PsiElement(Py:IDENTIFIER)('sub') + PyArgumentList + PsiElement(Py:LPAR)('(') + PyStringLiteralExpression: + PsiElement(Py:STRING_LITERAL)('r"""\\\\"""') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyStringLiteralExpression: \ + PsiElement(Py:STRING_LITERAL)('r"""\"""') + PsiElement(Py:COMMA)(',') + PsiWhiteSpace(' ') + PyReferenceExpression: str + PsiElement(Py:IDENTIFIER)('str') + PsiElement(Py:RPAR)(')') \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PythonLexerTest.java b/python/testSrc/com/jetbrains/python/PythonLexerTest.java index b803d255547c..d0d92ff7d0ee 100644 --- a/python/testSrc/com/jetbrains/python/PythonLexerTest.java +++ b/python/testSrc/com/jetbrains/python/PythonLexerTest.java @@ -125,6 +125,10 @@ public class PythonLexerTest extends TestCase { doTest("0b0101", "Py:INTEGER_LITERAL"); } + public void testLongString() throws Exception { + doTest("\"\"\"\"\"\"\na", "Py:STRING_LITERAL", "Py:STATEMENT_BREAK", "Py:LINE_BREAK", "Py:IDENTIFIER"); + } + public void _testWithKeyword() throws Exception { // processing of 'from __future__ import' is now done on parser level, so a pure lexer test won't handle // this correctly diff --git a/python/testSrc/com/jetbrains/python/PythonParsingTest.java b/python/testSrc/com/jetbrains/python/PythonParsingTest.java index d8bff032ffaf..b8da5eb1a220 100644 --- a/python/testSrc/com/jetbrains/python/PythonParsingTest.java +++ b/python/testSrc/com/jetbrains/python/PythonParsingTest.java @@ -190,6 +190,10 @@ public class PythonParsingTest extends ParsingTestCase { doTest(LanguageLevel.PYTHON31); } + public void testLongString() throws Exception { + doTest(); + } + public void doTest() throws Exception { doTest(LanguageLevel.PYTHON25); }