'...' reserved as a token

KT-9708 Ambiguous syntax for Double ranges: `.1...2` (triple dot)

 #KT-9708 Fixed
This commit is contained in:
Andrey Breslav
2015-11-27 15:17:04 +03:00
parent 877129340f
commit aca355acdc
10 changed files with 768 additions and 627 deletions
@@ -1,4 +1,4 @@
/* The following code was generated by JFlex 1.4.3 on 10/9/15 5:11 PM */
/* The following code was generated by JFlex 1.4.3 on 11/27/15 4:10 PM */
package org.jetbrains.kotlin.kdoc.lexer;
@@ -7,15 +7,14 @@ import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.text.CharArrayUtil;
import java.lang.Character;
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 10/9/15 5:11 PM from the specification file
* <tt>/Users/yole/jetbrains/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
* on 11/27/15 4:10 PM from the specification file
* <tt>/Users/abreslav/work/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
*/
class _KDocLexer implements FlexLexer {
/** initial size of the lookahead buffer */
@@ -47,63 +46,81 @@ class _KDocLexer implements FlexLexer {
"\1\14\1\15\1\10\3\0\1\4\1\7\12\2\6\0\1\11\32\3"+
"\1\5\1\13\1\6\1\0\1\3\1\0\32\3\47\0\4\3\4\0"+
"\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0\37\3\1\0"+
"\u013f\3\31\0\162\3\4\0\14\3\16\0\5\3\11\0\1\3\213\0"+
"\1\3\13\0\1\3\1\0\3\3\1\0\1\3\1\0\24\3\1\0"+
"\54\3\1\0\46\3\1\0\5\3\4\0\202\3\10\0\105\3\1\0"+
"\46\3\2\0\2\3\6\0\20\3\41\0\46\3\2\0\1\3\7\0"+
"\47\3\110\0\33\3\5\0\3\3\56\0\32\3\5\0\13\3\43\0"+
"\2\3\1\0\143\3\1\0\1\3\17\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
"\7\3\1\0\77\3\1\0\1\3\1\0\4\3\2\0\7\3\1\0"+
"\1\3\1\0\4\3\2\0\47\3\1\0\1\3\1\0\4\3\2\0"+
"\37\3\1\0\1\3\1\0\4\3\2\0\7\3\1\0\1\3\1\0"+
"\4\3\2\0\7\3\1\0\7\3\1\0\27\3\1\0\37\3\1\0"+
"\1\3\1\0\4\3\2\0\7\3\1\0\47\3\1\0\23\3\105\0"+
"\125\3\14\0\u026c\3\2\0\10\3\12\0\32\3\5\0\113\3\3\0"+
"\3\3\17\0\15\3\1\0\4\3\16\0\22\3\16\0\22\3\16\0"+
"\15\3\1\0\3\3\17\0\64\3\43\0\1\3\3\0\2\3\103\0"+
"\130\3\10\0\51\3\127\0\35\3\63\0\36\3\2\0\5\3\u038b\0"+
"\154\3\224\0\234\3\4\0\132\3\6\0\26\3\2\0\6\3\2\0"+
"\46\3\2\0\6\3\2\0\10\3\1\0\1\3\1\0\1\3\1\0"+
"\1\3\1\0\37\3\2\0\65\3\1\0\7\3\1\0\1\3\3\0"+
"\3\3\1\0\7\3\3\0\4\3\2\0\6\3\4\0\15\3\5\0"+
"\3\3\1\0\7\3\102\0\2\3\23\0\1\3\34\0\1\3\15\0"+
"\1\3\40\0\22\3\120\0\1\3\4\0\1\3\2\0\12\3\1\0"+
"\1\3\3\0\5\3\6\0\1\3\1\0\1\3\1\0\1\3\1\0"+
"\4\3\1\0\3\3\1\0\7\3\3\0\3\3\5\0\5\3\26\0"+
"\44\3\u0e81\0\3\3\31\0\11\3\7\0\5\3\2\0\5\3\4\0"+
"\126\3\6\0\3\3\1\0\137\3\5\0\50\3\4\0\136\3\21\0"+
"\30\3\70\0\20\3\u0200\0\u19b6\3\112\0\u51a6\3\132\0\u048d\3\u0773\0"+
"\u2ba4\3\u215c\0\u012e\3\2\0\73\3\225\0\7\3\14\0\5\3\5\0"+
"\1\3\1\0\12\3\1\0\15\3\1\0\5\3\1\0\1\3\1\0"+
"\2\3\1\0\2\3\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0"+
"\66\3\50\0\15\3\66\0\2\3\30\0\3\3\31\0\1\3\6\0"+
"\5\3\1\0\207\3\7\0\1\3\34\0\32\3\4\0\1\3\1\0"+
"\32\3\12\0\132\3\3\0\6\3\2\0\6\3\2\0\6\3\2\0"+
"\3\3\3\0\2\3\3\0\2\3\31\0";
"\1\3\1\0\2\3\17\0\2\3\22\0\10\3\1\0\3\3\1\0"+
"\51\3\2\0\1\3\20\0\1\3\21\0\2\3\30\0\6\3\5\0"+
"\22\3\3\0\30\3\1\0\11\3\1\0\1\3\2\0\7\3\72\0"+
"\60\3\1\0\2\3\13\0\10\3\72\0\2\3\1\0\1\3\2\0"+
"\2\3\1\0\1\3\2\0\1\3\6\0\4\3\1\0\7\3\1\0"+
"\3\3\1\0\1\3\1\0\1\3\2\0\2\3\1\0\4\3\1\0"+
"\2\3\11\0\1\3\2\0\5\3\1\0\1\3\25\0\2\3\42\0"+
"\1\3\77\0\10\3\1\0\44\3\33\0\5\3\163\0\53\3\24\0"+
"\1\3\20\0\6\3\4\0\4\3\3\0\1\3\3\0\2\3\7\0"+
"\3\3\4\0\15\3\14\0\1\3\21\0\46\3\12\0\53\3\1\0"+
"\1\3\3\0\u0149\3\1\0\4\3\2\0\7\3\1\0\1\3\1\0"+
"\4\3\2\0\51\3\1\0\4\3\2\0\41\3\1\0\4\3\2\0"+
"\7\3\1\0\1\3\1\0\4\3\2\0\17\3\1\0\71\3\1\0"+
"\4\3\2\0\103\3\45\0\20\3\20\0\125\3\14\0\u026c\3\2\0"+
"\21\3\1\0\32\3\5\0\113\3\3\0\3\3\17\0\15\3\1\0"+
"\4\3\16\0\22\3\16\0\22\3\16\0\15\3\1\0\3\3\17\0"+
"\64\3\43\0\1\3\3\0\2\3\103\0\130\3\10\0\51\3\1\0"+
"\1\3\5\0\106\3\12\0\35\3\63\0\36\3\2\0\5\3\13\0"+
"\54\3\25\0\7\3\70\0\27\3\11\0\65\3\122\0\1\3\135\0"+
"\57\3\21\0\7\3\67\0\36\3\15\0\2\3\20\0\46\3\32\0"+
"\44\3\51\0\3\3\12\0\44\3\153\0\4\3\1\0\4\3\16\0"+
"\300\3\100\0\u0116\3\2\0\6\3\2\0\46\3\2\0\6\3\2\0"+
"\10\3\1\0\1\3\1\0\1\3\1\0\1\3\1\0\37\3\2\0"+
"\65\3\1\0\7\3\1\0\1\3\3\0\3\3\1\0\7\3\3\0"+
"\4\3\2\0\6\3\4\0\15\3\5\0\3\3\1\0\7\3\102\0"+
"\2\3\23\0\1\3\34\0\1\3\15\0\1\3\20\0\15\3\3\0"+
"\32\3\110\0\1\3\4\0\1\3\2\0\12\3\1\0\1\3\3\0"+
"\5\3\6\0\1\3\1\0\1\3\1\0\1\3\1\0\4\3\1\0"+
"\13\3\2\0\4\3\5\0\5\3\4\0\1\3\21\0\51\3\u0a77\0"+
"\57\3\1\0\57\3\1\0\205\3\6\0\4\3\21\0\46\3\12\0"+
"\66\3\11\0\1\3\20\0\27\3\11\0\7\3\1\0\7\3\1\0"+
"\7\3\1\0\7\3\1\0\7\3\1\0\7\3\1\0\7\3\1\0"+
"\7\3\120\0\1\3\u01d5\0\3\3\31\0\11\3\7\0\5\3\2\0"+
"\5\3\4\0\126\3\6\0\3\3\1\0\132\3\1\0\4\3\5\0"+
"\51\3\3\0\136\3\21\0\33\3\65\0\20\3\u0200\0\u19b6\3\112\0"+
"\u51cc\3\64\0\u048d\3\103\0\56\3\2\0\u010d\3\3\0\20\3\12\0"+
"\2\3\24\0\57\3\20\0\31\3\10\0\120\3\47\0\11\3\2\0"+
"\147\3\2\0\4\3\1\0\2\3\16\0\12\3\120\0\10\3\1\0"+
"\3\3\1\0\4\3\1\0\27\3\25\0\1\3\7\0\64\3\16\0"+
"\62\3\76\0\6\3\3\0\1\3\16\0\34\3\12\0\27\3\31\0"+
"\35\3\7\0\57\3\34\0\1\3\60\0\51\3\27\0\3\3\1\0"+
"\10\3\24\0\27\3\3\0\1\3\5\0\60\3\1\0\1\3\3\0"+
"\2\3\2\0\5\3\2\0\1\3\1\0\1\3\30\0\3\3\43\0"+
"\6\3\2\0\6\3\2\0\6\3\11\0\7\3\1\0\7\3\221\0"+
"\43\3\35\0\u2ba4\3\14\0\27\3\4\0\61\3\u2104\0\u012e\3\2\0"+
"\76\3\2\0\152\3\46\0\7\3\14\0\5\3\5\0\1\3\1\0"+
"\12\3\1\0\15\3\1\0\5\3\1\0\1\3\1\0\2\3\1\0"+
"\2\3\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0\66\3\50\0"+
"\15\3\66\0\2\3\30\0\3\3\31\0\1\3\6\0\5\3\1\0"+
"\207\3\7\0\1\3\34\0\32\3\4\0\1\3\1\0\32\3\13\0"+
"\131\3\3\0\6\3\2\0\6\3\2\0\6\3\2\0\3\3\3\0"+
"\2\3\3\0\2\3\31\0";
/**
* Translates characters to character classes
@@ -341,7 +358,7 @@ class _KDocLexer implements FlexLexer {
char [] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 1212) {
while (i < 1568) {
int count = packed.charAt(i++);
char value = packed.charAt(i++);
do map[j++] = value; while (--count > 0);
@@ -268,6 +268,7 @@ LONG_TEMPLATE_ENTRY_START=\$\{
\!in{IDENTIFIER_PART} { yypushback(3); return KtTokens.EXCL; }
\!is{IDENTIFIER_PART} { yypushback(3); return KtTokens.EXCL; }
"..." { return KtTokens.RESERVED ; }
"===" { return KtTokens.EQEQEQ ; }
"!==" { return KtTokens.EXCLEQEQEQ; }
"!in" { return KtTokens.NOT_IN; }
@@ -25,6 +25,8 @@ import org.jetbrains.kotlin.psi.KtPsiUtil;
public interface KtTokens {
KtToken EOF = new KtToken("EOF");
KtToken RESERVED = new KtToken("RESERVED");
KtToken BLOCK_COMMENT = new KtToken("BLOCK_COMMENT");
KtToken EOL_COMMENT = new KtToken("EOL_COMMENT");
KtToken SHEBANG_COMMENT = new KtToken("SHEBANG_COMMENT");
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -33,8 +33,8 @@ import -
import ^_^
import .
import ---; import +++
import ..{...
import ..}...
import ..{.. .
import ..}.. .
import foo
fun foo() {
+2
View File
@@ -366,6 +366,7 @@ JetFile: Imports_ERR.kt
PsiElement(RANGE)('..')
PsiElement(LBRACE)('{')
PsiElement(RANGE)('..')
PsiWhiteSpace(' ')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
@@ -375,6 +376,7 @@ JetFile: Imports_ERR.kt
PsiElement(RANGE)('..')
PsiElement(RBRACE)('}')
PsiElement(RANGE)('..')
PsiWhiteSpace(' ')
PsiElement(DOT)('.')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
+11
View File
@@ -0,0 +1,11 @@
...
fun foo() {
for (i in 1...2) {
}
for (i in 1.. .2) {
}
}
+75
View File
@@ -0,0 +1,75 @@
JetFile: TripleDot.kt
PACKAGE_DIRECTIVE
<empty list>
IMPORT_LIST
<empty list>
PsiErrorElement:Expecting a top level declaration
PsiElement(RESERVED)('...')
PsiWhiteSpace('\n\n')
FUN
PsiElement(fun)('fun')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('foo')
VALUE_PARAMETER_LIST
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n ')
FOR
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('i')
PsiWhiteSpace(' ')
PsiElement(in)('in')
PsiWhiteSpace(' ')
LOOP_RANGE
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
PsiErrorElement:Expecting ')'
<empty list>
BODY
<empty list>
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
PsiElement(RESERVED)('...')
PsiElement(INTEGER_LITERAL)('2')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
FUNCTION_LITERAL_EXPRESSION
FUNCTION_LITERAL
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
BLOCK
<empty list>
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n ')
FOR
PsiElement(for)('for')
PsiWhiteSpace(' ')
PsiElement(LPAR)('(')
VALUE_PARAMETER
PsiElement(IDENTIFIER)('i')
PsiWhiteSpace(' ')
PsiElement(in)('in')
PsiWhiteSpace(' ')
LOOP_RANGE
BINARY_EXPRESSION
INTEGER_CONSTANT
PsiElement(INTEGER_LITERAL)('1')
OPERATION_REFERENCE
PsiElement(RANGE)('..')
PsiWhiteSpace(' ')
FLOAT_CONSTANT
PsiElement(FLOAT_CONSTANT)('.2')
PsiElement(RPAR)(')')
PsiWhiteSpace(' ')
BODY
BLOCK
PsiElement(LBRACE)('{')
PsiWhiteSpace('\n\n ')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
+1 -2
View File
@@ -21,8 +21,7 @@ JetFile: MarkdownLinkWithError.kt
PsiElement(IDENTIFIER)('C')
PsiErrorElement:Closing bracket expected
<empty list>
PsiElement(RANGE)('..')
PsiElement(DOT)('.')
PsiElement(RESERVED)('...')
PsiElement(RBRACKET)(']')
PsiWhiteSpace('\n ')
PsiElement(KDOC_LEADING_ASTERISK)('*')
@@ -715,6 +715,12 @@ public class ParsingTestGenerated extends AbstractParsingTest {
doParsingTest(fileName);
}
@TestMetadata("TripleDot.kt")
public void testTripleDot() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/TripleDot.kt");
doParsingTest(fileName);
}
@TestMetadata("TryRecovery.kt")
public void testTryRecovery() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/psi/TryRecovery.kt");