Temporary parse label definitions with both syntax versions
Should be reverted after bootstrap
This commit is contained in:
@@ -554,10 +554,15 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
return lookahead(2) == LBRACE;
|
||||
}
|
||||
|
||||
if (at(AT) && myBuilder.rawLookup(1) == IDENTIFIER) {
|
||||
return lookahead(2) == LBRACE;
|
||||
}
|
||||
|
||||
return at(AT) && lookahead(1) == LBRACE;
|
||||
}
|
||||
|
||||
private boolean isAtLabelDefinitionOrMissingIdentifier() {
|
||||
if (at(AT) && myBuilder.rawLookup(1) == IDENTIFIER) return true;
|
||||
return (at(IDENTIFIER) && myBuilder.rawLookup(1) == AT) || at(AT);
|
||||
}
|
||||
|
||||
@@ -1659,8 +1664,22 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
*/
|
||||
private void parseLabelDefinition() {
|
||||
if (at(AT)) {
|
||||
// recovery for empty label identifier
|
||||
errorAndAdvance("Label must be named"); // AT
|
||||
// recovery for old label syntax or empty label identifier
|
||||
if (myBuilder.rawLookup(1) == IDENTIFIER) {
|
||||
PsiBuilder.Marker labelWrap = mark();
|
||||
PsiBuilder.Marker mark = mark();
|
||||
|
||||
advance(); // AT
|
||||
advance(); // IDENTIFIER
|
||||
|
||||
mark.done(LABEL);
|
||||
|
||||
labelWrap.done(LABEL_QUALIFIER);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
errorAndAdvance("Label must be named"); // AT
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,61 +13,63 @@ JetFile: oldSyntaxExpressions.kt
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('loop1')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
FOR
|
||||
PsiElement(for)('for')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('loop1')
|
||||
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)('..')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('100')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
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)('..')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('100')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BODY
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
DOT_QUALIFIED_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('x2')
|
||||
PsiElement(DOT)('.')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('filter')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
FUNCTION_LITERAL_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
BLOCK
|
||||
RETURN
|
||||
PsiElement(return)('return')
|
||||
CALL_EXPRESSION
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('filter')
|
||||
PsiWhiteSpace(' ')
|
||||
FUNCTION_LITERAL_ARGUMENT
|
||||
LABELED_EXPRESSION
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
FUNCTION_LITERAL_EXPRESSION
|
||||
FUNCTION_LITERAL
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
BLOCK
|
||||
RETURN
|
||||
PsiElement(return)('return')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
RETURN
|
||||
PsiElement(return)('return')
|
||||
@@ -75,16 +77,14 @@ JetFile: oldSyntaxExpressions.kt
|
||||
PARENTHESIZED
|
||||
PsiElement(LPAR)('(')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('f')
|
||||
PsiErrorElement:Expecting ')'
|
||||
<empty list>
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
PsiElement(RPAR)(')')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('f')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
|
||||
@@ -123,13 +123,13 @@ JetFile: recovery.kt
|
||||
PsiElement(return)('return')
|
||||
PsiWhiteSpace('\n ')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('loop2')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('4')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('loop2')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('4')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
|
||||
@@ -33,13 +33,13 @@ JetFile: spaceBeforeLabelReference.kt
|
||||
PsiElement(return)('return')
|
||||
PsiWhiteSpace(' ')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('l2')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('l2')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
@@ -55,20 +55,20 @@ JetFile: spaceBeforeLabelReference.kt
|
||||
PsiElement(return)('return')
|
||||
PsiWhiteSpace(' ')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('l3')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('l3')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
CONTINUE
|
||||
PsiElement(continue)('continue')
|
||||
@@ -111,33 +111,33 @@ JetFile: spaceBeforeLabelReference.kt
|
||||
PsiWhiteSpace(' ')
|
||||
PsiComment(BLOCK_COMMENT)('/**/')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('l6')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('8')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('l6')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('8')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
RETURN
|
||||
PsiElement(return)('return')
|
||||
PsiComment(EOL_COMMENT)('//')
|
||||
PsiWhiteSpace('\n')
|
||||
LABELED_EXPRESSION
|
||||
PsiErrorElement:Label must be named
|
||||
PsiElement(AT)('@')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('l7')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line)
|
||||
PsiElement(INTEGER_LITERAL)('4')
|
||||
LABEL_QUALIFIER
|
||||
LABEL
|
||||
PsiElement(AT)('@')
|
||||
PsiElement(IDENTIFIER)('l7')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('4')
|
||||
PsiWhiteSpace('\n\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
|
||||
Reference in New Issue
Block a user