rename expand to inline

This commit is contained in:
2026-08-02 20:31:05 +02:00
parent c92723bc14
commit 9e79d6692b
13 changed files with 123 additions and 82 deletions
+8 -17
View File
@@ -1813,16 +1813,7 @@ parse_value_control_flow :: proc(parser: ^Parser) -> (ast.Stmt_Id, bool) {
}
parse_statement :: proc(parser: ^Parser) -> ast.Stmt_Id {
if current(parser).kind == .Identifier && token_text(parser, current(parser)) == "inline" &&
peek(parser).kind == .Keyword_For {
start := advance(parser)
id := parse_for(parser)
parser.module.statements[id].expand = true
parser.module.statements[id].span = span_from(start.span, parser.module.statements[id].span)
source.add(parser.diagnostics, start.span, "'inline for' was renamed to 'expand for'")
return id
}
if current(parser).kind == .Keyword_Expand && peek(parser).kind == .Keyword_For {
if current(parser).kind == .Keyword_Inline && peek(parser).kind == .Keyword_For {
start := advance(parser)
id := parse_for(parser)
parser.module.statements[id].expand = true
@@ -2266,7 +2257,7 @@ parse_arm_body :: proc(parser: ^Parser) -> []ast.Stmt_Id {
}
// parse_match_arm parses one `<pattern,...> [|[@]capture|]: <body>`, `else: <body>`,
// or `expand |[@]value[, tag]|: <body>` arm.
// or `inline |[@]value[, tag]|: <body>` arm.
parse_match_arm :: proc(parser: ^Parser) -> ast.Stmt_Id {
start := current(parser).span
patterns: [dynamic]ast.Expr_Id
@@ -2275,10 +2266,10 @@ parse_match_arm :: proc(parser: ^Parser) -> ast.Stmt_Id {
captures.allocator = parser.module.allocator
pointer_capture := false
expand := false
if _, is_expand := allow(parser, .Keyword_Expand); is_expand {
if _, is_expand := allow(parser, .Keyword_Inline); is_expand {
expand = true
if _, ok := allow(parser, .Pipe); !ok {
source.add(parser.diagnostics, current(parser).span, "expected '|' before expand captures")
source.add(parser.diagnostics, current(parser).span, "expected '|' before inline captures")
} else {
if _, at_ok := allow(parser, .At); at_ok {
pointer_capture = true
@@ -2288,7 +2279,7 @@ parse_match_arm :: proc(parser: ^Parser) -> ast.Stmt_Id {
advance(parser)
append(&captures, name_tok.symbol)
} else {
source.add(parser.diagnostics, current(parser).span, "expected an expand value capture")
source.add(parser.diagnostics, current(parser).span, "expected an inline value capture")
}
if _, comma_ok := allow(parser, .Comma); comma_ok {
tag_tok := current(parser)
@@ -2296,10 +2287,10 @@ parse_match_arm :: proc(parser: ^Parser) -> ast.Stmt_Id {
advance(parser)
append(&captures, tag_tok.symbol)
} else {
source.add(parser.diagnostics, current(parser).span, "expected an expand tag capture")
source.add(parser.diagnostics, current(parser).span, "expected an inline tag capture")
}
if _, extra := allow(parser, .Comma); extra {
source.add(parser.diagnostics, current(parser).span, "'expand' accepts at most two captures")
source.add(parser.diagnostics, current(parser).span, "'inline' accepts at most two captures")
for current(parser).kind != .Pipe && current(parser).kind != .Colon &&
current(parser).kind != .Newline && current(parser).kind != .Eof {
advance(parser)
@@ -2307,7 +2298,7 @@ parse_match_arm :: proc(parser: ^Parser) -> ast.Stmt_Id {
}
}
if _, close_ok := allow(parser, .Pipe); !close_ok {
source.add(parser.diagnostics, current(parser).span, "expected '|' to close expand captures")
source.add(parser.diagnostics, current(parser).span, "expected '|' to close inline captures")
}
}
} else if _, is_else := allow(parser, .Keyword_Else); !is_else {