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(); myBuilder.disableNewlines();
advance(); // LPAR advance(); // LPAR
int commaPassed = 0; boolean tuple = false;
if (!at(RPAR)) { if (!at(RPAR)) {
while (true) { while (true) {
while (at(COMMA)) { while (at(COMMA)) {
commaPassed++; tuple = true;
errorAndAdvance("Expecting a tuple entry (expression)"); errorAndAdvance("Expecting a tuple entry (expression)");
} }
@@ -1245,19 +1245,21 @@ public class JetExpressionParsing extends AbstractJetParsing {
if (!at(COMMA)) break; if (!at(COMMA)) break;
advance(); // COMMA advance(); // COMMA
commaPassed++; tuple = true;
if (at(RPAR)) { if (at(RPAR)) {
error("Expecting a tuple entry (expression)"); error("Expecting a tuple entry (expression)");
break; break;
} }
} }
} else {
tuple = true;
} }
expect(RPAR, "Expecting ')'"); expect(RPAR, "Expecting ')'");
myBuilder.restoreNewlinesState(); 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 REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('T') PsiElement(IDENTIFIER)('T')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
PARENTHESIZED TUPLE
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
+1 -1
View File
@@ -20,7 +20,7 @@ JetFile: SimpleExpressions.jet
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PARENTHESIZED TUPLE
PsiElement(LPAR)('(') PsiElement(LPAR)('(')
PsiElement(RPAR)(')') PsiElement(RPAR)(')')
PsiElement(COMMA)(',') PsiElement(COMMA)(',')