Lables: break and continue accept only string literals
This commit is contained in:
@@ -191,11 +191,16 @@ infixFunctionCall
|
|||||||
jump
|
jump
|
||||||
: "throw" expression
|
: "throw" expression
|
||||||
: "return" expression?
|
: "return" expression?
|
||||||
: "continue" SimpleName
|
: "continue" stringLiteral?
|
||||||
: "break" SimpleName
|
: "break" stringLiteral?
|
||||||
// yield ?
|
// yield ?
|
||||||
;
|
;
|
||||||
|
|
||||||
|
stringLiteral
|
||||||
|
: StringWithTemplates
|
||||||
|
: NoEscapeString
|
||||||
|
;
|
||||||
|
|
||||||
tupleLiteral // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an expression in parentheses
|
tupleLiteral // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an expression in parentheses
|
||||||
// to put a tuple, write write ((e))
|
// to put a tuple, write write ((e))
|
||||||
: "(" ((SimpleName "=")? expression){","} ")"
|
: "(" ((SimpleName "=")? expression){","} ")"
|
||||||
|
|||||||
@@ -957,8 +957,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* : "continue" SimpleName
|
* : "continue" stringLiteral?
|
||||||
* : "break" SimpleName
|
* : "break" stringLiteral?
|
||||||
|
*
|
||||||
|
* stringLiteral
|
||||||
|
* : StringWithTemplates
|
||||||
|
* : NoEscapeString
|
||||||
|
* ;
|
||||||
*/
|
*/
|
||||||
private void parseJump(JetNodeType type) {
|
private void parseJump(JetNodeType type) {
|
||||||
assert _at(BREAK_KEYWORD) || _at(CONTINUE_KEYWORD);
|
assert _at(BREAK_KEYWORD) || _at(CONTINUE_KEYWORD);
|
||||||
@@ -967,7 +972,7 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
|||||||
|
|
||||||
advance(); // BREAK_KEYWORD or CONTINUE_KEYWORD
|
advance(); // BREAK_KEYWORD or CONTINUE_KEYWORD
|
||||||
|
|
||||||
if (!eol() && at(IDENTIFIER)) advance(); // IDENTIFIER
|
if (!eol() && (at(RAW_STRING_LITERAL) || at(STRING_LITERAL))) advance(); // RAW_STRING_LITERAL or STRING_LITERAL
|
||||||
|
|
||||||
marker.done(type);
|
marker.done(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ fun a(
|
|||||||
a : foo = throw new Foo,
|
a : foo = throw new Foo,
|
||||||
a : foo = return 10,
|
a : foo = return 10,
|
||||||
a : foo = break,
|
a : foo = break,
|
||||||
a : foo = break la,
|
a : foo = break "la",
|
||||||
a : foo = continue,
|
a : foo = continue,
|
||||||
a : foo = continue la,
|
a : foo = continue "la",
|
||||||
a : foo = if (10) foo else bar,
|
a : foo = if (10) foo else bar,
|
||||||
a : foo = if (10) foo
|
a : foo = if (10) foo
|
||||||
) {
|
) {
|
||||||
@@ -13,11 +13,11 @@ fun a(
|
|||||||
return
|
return
|
||||||
10
|
10
|
||||||
break
|
break
|
||||||
la
|
"la"
|
||||||
break la
|
break "la"
|
||||||
continue
|
continue
|
||||||
la
|
"la"
|
||||||
continue la
|
continue "la"
|
||||||
if (foo)
|
if (foo)
|
||||||
if (foo)
|
if (foo)
|
||||||
bar
|
bar
|
||||||
@@ -75,6 +75,7 @@ fun a(
|
|||||||
do {
|
do {
|
||||||
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
}
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
for (a in b)
|
for (a in b)
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ fun a(
|
|||||||
a : foo = throw new Foo,
|
a : foo = throw new Foo,
|
||||||
a : foo = return 10,
|
a : foo = return 10,
|
||||||
a : foo = break,
|
a : foo = break,
|
||||||
a : foo = break la,
|
a : foo = break "la",
|
||||||
a : foo = continue,
|
a : foo = continue,
|
||||||
a : foo = continue la,
|
a : foo = continue "la",
|
||||||
a : foo = 10,
|
a : foo = 10,
|
||||||
a : foo = 10,
|
a : foo = 10,
|
||||||
a : foo = 10,
|
a : foo = 10,
|
||||||
@@ -39,9 +39,9 @@ fun a(
|
|||||||
return
|
return
|
||||||
10
|
10
|
||||||
break
|
break
|
||||||
la
|
"la"
|
||||||
break la
|
break "la"
|
||||||
continue
|
continue
|
||||||
la
|
"la"
|
||||||
continue la
|
continue "la"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user