Fix () to be a 0-ary tuple, not empty PARENTHESIZED

This commit is contained in:
Andrey Breslav
2011-01-14 21:14:10 +03:00
parent 97df7d9116
commit 6cb2747a76
4 changed files with 9 additions and 7 deletions
@@ -1233,11 +1233,11 @@ public class JetExpressionParsing extends AbstractJetParsing {
myBuilder.disableNewlines();
advance(); // LPAR
int commaPassed = 0;
boolean tuple = false;
if (!at(RPAR)) {
while (true) {
while (at(COMMA)) {
commaPassed++;
tuple = true;
errorAndAdvance("Expecting a tuple entry (expression)");
}
@@ -1245,19 +1245,21 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (!at(COMMA)) break;
advance(); // COMMA
commaPassed++;
tuple = true;
if (at(RPAR)) {
error("Expecting a tuple entry (expression)");
break;
}
}
} else {
tuple = true;
}
expect(RPAR, "Expecting ')'");
myBuilder.restoreNewlinesState();
mark.done(commaPassed > 0 ? TUPLE : PARENTHESIZED);
mark.done(tuple ? TUPLE : PARENTHESIZED);
}
/*
+1 -1
View File
@@ -324,7 +324,7 @@ JetFile: NewlinesInParentheses.jet
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T')
PsiWhiteSpace('\n ')
PARENTHESIZED
TUPLE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
+1 -1
View File
@@ -32,4 +32,4 @@ fun foo() {
a || b && c
a = b -> c
a = b || c
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ')
PsiElement(EQ)('=')
PsiWhiteSpace(' ')
PARENTHESIZED
TUPLE
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiElement(COMMA)(',')