Skip to content

Commit 723a539

Browse files
committed
Fixed: loop labels
1 parent 7d45d57 commit 723a539

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/scala/plus/meow/MeowRust/parser/expression.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ trait Expression extends RegexParsers with Literal with Pattern with Identifier
151151
// TODO: add type ascription
152152
lazy val CLOSURE_PARAM = PATTERN
153153

154-
lazy val LOOP_EXPRESSION: Parser[Expr] = (LOOP_LABEL?) ~ (
154+
lazy val LOOP_EXPRESSION: Parser[Expr] = ((LOOP_LABEL?) <~ separator) ~? (
155155
"loop" ~>? BLOCK_EXPRESSION ^^ { b => l: Option[String] => InftyLoopExpr(l, b) }
156156
| "while" ~>! EXPRESSION ~? BLOCK_EXPRESSION ^^ { (c, b) => l: Option[String] => WhileExpr(l, c, b) }
157157
| (("while" ~! "let") ~>! MATCH_ARM_PATTERNS <~? "=") ~? EXPRESSION ~? BLOCK_EXPRESSION ^^ { (p, u, b) => l: Option[String] => WhileLetExpr(l, p, u, b) }

testcases/typing_loop.txt

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
loop {
2-
let ident = (1, "b", 222.222f64);
3-
break if true {
4-
ident.1
5-
} else {
6-
"456"
1+
'outer: loop {
2+
while true {
3+
let ident = (1, "b", 222.222f64);
4+
break 'outer if true {
5+
ident.1
6+
} else {
7+
"456"
8+
}
79
}
810
}

0 commit comments

Comments
 (0)