aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-11-01 01:32:46 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-11-01 01:32:46 -0400
commite2b276f3ea2b00640a028c5455c283aa45261908 (patch)
tree75cea6bc3969df7d3519497088de22f196a7b30c
parentf0051365929886befc20cbee442496ec3eeeb5ed (diff)
Parse empty idents after selector as a selector expr with an empty field
-rw-r--r--core/odin/parser/parser.odin17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin
index 7ebe275ed..9ce484a10 100644
--- a/core/odin/parser/parser.odin
+++ b/core/odin/parser/parser.odin
@@ -3210,6 +3210,17 @@ parse_call_expr :: proc(p: ^Parser, operand: ^ast.Expr) -> ^ast.Expr {
return ce
}
+empty_selector_expr :: proc(tok: tokenizer.Token, operand: ^ast.Expr) -> ^ast.Selector_Expr {
+ field := ast.new(ast.Ident, tok.pos, end_pos(tok))
+ field.name = ""
+
+ sel := ast.new(ast.Selector_Expr, operand.pos, field)
+ sel.expr = operand
+ sel.op = tok
+ sel.field = field
+
+ return sel
+}
parse_atom_expr :: proc(p: ^Parser, value: ^ast.Expr, lhs: bool) -> (operand: ^ast.Expr) {
operand = value
@@ -3343,8 +3354,7 @@ parse_atom_expr :: proc(p: ^Parser, value: ^ast.Expr, lhs: bool) -> (operand: ^a
case:
error(p, p.curr_tok.pos, "expected a selector")
- advance_token(p)
- operand = ast.new(ast.Bad_Expr, operand.pos, end_pos(tok))
+ operand = empty_selector_expr(tok, operand)
}
case .Arrow_Right:
@@ -3361,8 +3371,7 @@ parse_atom_expr :: proc(p: ^Parser, value: ^ast.Expr, lhs: bool) -> (operand: ^a
operand = sel
case:
error(p, p.curr_tok.pos, "expected a selector")
- advance_token(p)
- operand = ast.new(ast.Bad_Expr, operand.pos, end_pos(tok))
+ operand = empty_selector_expr(tok, operand)
}
case .Pointer: