From 55c11539f82a196556371bf5adb92439dcb6a638 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 14 Jul 2015 14:59:47 +0200 Subject: [PATCH] drop tuples support from parser --- .../kotlin/parsing/JetExpressionParsing.java | 47 ------------------- .../testData/psi/script/ShebangIncorrect.txt | 32 +++++-------- 2 files changed, 12 insertions(+), 67 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index f124063866b..41aef763d22 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -604,7 +604,6 @@ public class JetExpressionParsing extends AbstractJetParsing { /* * atomicExpression - * : tupleLiteral // or parenthesized element * : "this" label? * : "super" ("<" type ">")? label? * : objectLiteral @@ -628,9 +627,6 @@ public class JetExpressionParsing extends AbstractJetParsing { if (at(LPAR)) { parseParenthesizedExpression(); } - else if (at(HASH)) { - parseTupleExpression(); - } else if (at(PACKAGE_KEYWORD)) { parseOneTokenExpression(ROOT_PACKAGE); } @@ -1782,49 +1778,6 @@ public class JetExpressionParsing extends AbstractJetParsing { mark.done(PARENTHESIZED); } - /* - * tupleLiteral - * : "#" "(" (((SimpleName "=")? expression){","})? ")" - * ; - */ - @Deprecated // Tuples are dropped, but parsing is left to minimize surprising. This code should be removed some time (in Kotlin 1.0?) - private void parseTupleExpression() { - assert _at(HASH); - PsiBuilder.Marker mark = mark(); - - advance(); // HASH - advance(); // LPAR - myBuilder.disableNewlines(); - if (!at(RPAR)) { - while (true) { - while (at(COMMA)) { - advance(); - } - - if (at(IDENTIFIER) && lookahead(1) == EQ) { - advance(); // IDENTIFIER - advance(); // EQ - parseExpression(); - } - else { - parseExpression(); - } - - if (!at(COMMA)) break; - advance(); // COMMA - - if (at(RPAR)) { - break; - } - } - - } - consumeIf(RPAR); - myBuilder.restoreNewlinesState(); - - mark.error("Tuples are not supported. Use data classes instead."); - } - /* * "this" label? */ diff --git a/compiler/testData/psi/script/ShebangIncorrect.txt b/compiler/testData/psi/script/ShebangIncorrect.txt index b7abfe89664..e1f21b76705 100644 --- a/compiler/testData/psi/script/ShebangIncorrect.txt +++ b/compiler/testData/psi/script/ShebangIncorrect.txt @@ -16,24 +16,16 @@ JetFile: ShebangIncorrect.kts PsiElement(RPAR)(')') PsiElement(SEMICOLON)(';') PsiWhiteSpace(' ') - BINARY_EXPRESSION - PsiErrorElement:Tuples are not supported. Use data classes instead. - PsiElement(HASH)('#') - PsiElement(EXCL)('!') - PsiErrorElement:Expecting an expression - - OPERATION_REFERENCE - PsiElement(DIV)('/') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('usr') + PsiErrorElement:Expecting an element + PsiElement(HASH)('#') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(EXCL)('!') + PsiElement(DIV)('/') + PsiElement(IDENTIFIER)('usr') PsiWhiteSpace('\n\n') - BINARY_EXPRESSION - PsiErrorElement:Tuples are not supported. Use data classes instead. - PsiElement(HASH)('#') - PsiElement(EXCL)('!') - PsiErrorElement:Expecting an expression - - OPERATION_REFERENCE - PsiElement(DIV)('/') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('hi') + PsiErrorElement:Expecting an element + PsiElement(HASH)('#') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(EXCL)('!') + PsiElement(DIV)('/') + PsiElement(IDENTIFIER)('hi') \ No newline at end of file