PY-18254 Parse new function type annotation introduced in PEP 484

This commit is contained in:
Mikhail Golubev
2016-02-09 18:23:41 +03:00
parent 39d90672d7
commit 28a893325c
4 changed files with 208 additions and 39 deletions
@@ -1,4 +1,4 @@
/* The following code was generated by JFlex 1.4.3 on 4/26/14 11:34 AM */
/* The following code was generated by JFlex 1.4.3 on 2/9/16 5:31 PM */
package com.jetbrains.python.psi.types;
@@ -11,8 +11,8 @@ import static com.jetbrains.python.psi.types.PyTypeTokenTypes.*;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 4/26/14 11:34 AM from the specification file
* <tt>/Users/ignatov/src/ultimate/tools/lexer/../../community/python/src/com/jetbrains/python/psi/types/PyType.flex</tt>
* on 2/9/16 5:31 PM from the specification file
* <tt>/home/east825/develop/repos/IDEA/community/python/src/com/jetbrains/python/psi/types/PyType.flex</tt>
*/
public class PyTypeLexer implements FlexLexer {
/** initial size of the lookahead buffer */
@@ -35,12 +35,12 @@ public class PyTypeLexer implements FlexLexer {
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\11\0\1\2\1\1\2\0\1\1\22\0\1\2\1\13\6\0\2\30"+
"\2\0\1\30\1\26\1\30\1\0\12\33\1\3\1\0\1\24\1\25"+
"\1\27\2\0\23\14\7\31\1\30\1\0\1\30\1\0\1\32\1\12"+
"\1\10\1\32\1\6\2\32\1\21\5\32\1\7\1\22\1\32\1\17"+
"\1\4\1\32\1\20\1\11\1\23\4\32\1\5\1\32\1\15\1\30"+
"\1\16\1\13\uff81\0";
"\11\0\1\2\1\1\2\0\1\1\22\0\1\2\1\13\6\0\2\20"+
"\1\20\1\0\1\20\1\30\1\17\1\0\12\34\1\3\1\0\1\26"+
"\1\27\1\31\2\0\23\14\7\32\1\20\1\0\1\20\1\0\1\33"+
"\1\12\1\10\1\33\1\6\2\33\1\23\5\33\1\7\1\24\1\33"+
"\1\21\1\4\1\33\1\22\1\11\1\25\4\33\1\5\1\33\1\15"+
"\1\20\1\16\1\13\uff81\0";
/**
* Translates characters to character classes
@@ -53,12 +53,12 @@ public class PyTypeLexer implements FlexLexer {
private static final int [] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
"\1\0\1\1\1\2\1\0\1\3\1\4\4\3\2\0"+
"\1\5\1\6\2\0\1\5\1\3\2\0\1\3\5\0"+
"\1\4";
"\1\0\1\1\1\2\1\0\1\3\1\4\1\3\2\5"+
"\3\3\2\0\1\6\3\0\1\5\1\3\2\0\1\3"+
"\5\0\1\4";
private static int [] zzUnpackAction() {
int [] result = new int[27];
int [] result = new int[29];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -83,13 +83,13 @@ public class PyTypeLexer implements FlexLexer {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\34\0\70\0\124\0\160\0\70\0\214\0\250"+
"\0\304\0\340\0\374\0\u0118\0\70\0\214\0\u0134\0\u0150"+
"\0\160\0\u016c\0\u0188\0\u01a4\0\u01c0\0\u01dc\0\u01f8\0\u0214"+
"\0\u0230\0\u024c\0\u0268";
"\0\0\0\35\0\72\0\127\0\164\0\72\0\221\0\256"+
"\0\72\0\313\0\350\0\u0105\0\u0122\0\u013f\0\221\0\u015c"+
"\0\u0179\0\u0196\0\164\0\u01b3\0\u01d0\0\u01ed\0\u020a\0\u0227"+
"\0\u0244\0\u0261\0\u027e\0\u029b\0\u02b8";
private static int [] zzUnpackRowMap() {
int [] result = new int[27];
int [] result = new int[29];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -113,23 +113,24 @@ public class PyTypeLexer implements FlexLexer {
private static final String ZZ_TRANS_PACKED_0 =
"\1\0\1\2\1\3\1\4\6\5\1\6\1\0\1\7"+
"\1\0\1\6\1\10\1\5\1\11\1\5\1\12\1\13"+
"\1\0\1\14\1\0\1\15\1\16\1\5\2\0\1\2"+
"\72\0\1\17\1\0\1\20\31\0\6\5\2\0\1\5"+
"\2\0\5\5\5\0\3\5\4\0\6\5\2\0\1\5"+
"\1\6\1\0\5\5\5\0\3\5\4\0\6\5\2\0"+
"\1\5\2\0\1\5\2\21\2\5\5\0\3\5\4\0"+
"\6\5\2\0\1\5\2\0\1\5\1\22\3\5\5\0"+
"\3\5\4\0\6\5\2\0\1\5\2\0\1\21\4\5"+
"\5\0\3\5\25\0\1\15\35\0\1\15\11\0\1\23"+
"\35\0\1\24\30\0\6\5\2\0\1\5\2\0\1\25"+
"\4\5\5\0\3\5\3\0\1\26\40\0\1\27\27\0"+
"\6\5\2\0\1\5\2\0\3\5\1\21\1\5\5\0"+
"\3\5\6\0\1\20\36\0\1\30\33\0\1\31\25\0"+
"\1\32\42\0\1\33\34\0\1\6\20\0";
"\1\0\1\6\1\10\1\11\1\12\1\5\1\13\1\5"+
"\1\14\1\15\1\0\1\16\1\0\1\17\1\5\2\0"+
"\1\2\74\0\1\20\1\0\1\21\32\0\6\5\2\0"+
"\1\5\4\0\5\5\4\0\3\5\4\0\6\5\2\0"+
"\1\5\1\6\3\0\5\5\4\0\3\5\17\0\1\22"+
"\21\0\6\5\2\0\1\5\4\0\1\5\2\23\2\5"+
"\4\0\3\5\4\0\6\5\2\0\1\5\4\0\1\5"+
"\1\24\3\5\4\0\3\5\4\0\6\5\2\0\1\5"+
"\4\0\1\23\4\5\4\0\3\5\27\0\1\11\36\0"+
"\1\11\10\0\1\25\36\0\1\26\44\0\1\11\21\0"+
"\6\5\2\0\1\5\4\0\1\27\4\5\4\0\3\5"+
"\3\0\1\30\41\0\1\31\30\0\6\5\2\0\1\5"+
"\4\0\3\5\1\23\1\5\4\0\3\5\6\0\1\21"+
"\37\0\1\32\34\0\1\33\26\0\1\34\43\0\1\35"+
"\35\0\1\6\21\0";
private static int [] zzUnpackTrans() {
int [] result = new int[644];
int [] result = new int[725];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -170,11 +171,12 @@ public class PyTypeLexer implements FlexLexer {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\1\0\1\1\1\11\1\0\1\1\1\11\4\1\2\0"+
"\1\11\1\1\2\0\2\1\2\0\1\1\5\0\1\1";
"\1\0\1\1\1\11\1\0\1\1\1\11\2\1\1\11"+
"\3\1\2\0\1\1\3\0\2\1\2\0\1\1\5\0"+
"\1\1";
private static int [] zzUnpackAttribute() {
int [] result = new int[27];
int [] result = new int[29];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -257,7 +259,7 @@ public class PyTypeLexer implements FlexLexer {
char [] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 106) {
while (i < 108) {
int count = packed.charAt(i++);
char value = packed.charAt(i++);
do map[j++] = value; while (--count > 0);