mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-01 12:18:15 +00:00
Parse empty idents after selector as a selector expr with an empty field
This commit is contained in:
@@ -3210,6 +3210,17 @@ parse_call_expr :: proc(p: ^Parser, operand: ^ast.Expr) -> ^ast.Expr {
|
|||||||
return ce
|
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) {
|
parse_atom_expr :: proc(p: ^Parser, value: ^ast.Expr, lhs: bool) -> (operand: ^ast.Expr) {
|
||||||
operand = value
|
operand = value
|
||||||
@@ -3343,8 +3354,7 @@ parse_atom_expr :: proc(p: ^Parser, value: ^ast.Expr, lhs: bool) -> (operand: ^a
|
|||||||
|
|
||||||
case:
|
case:
|
||||||
error(p, p.curr_tok.pos, "expected a selector")
|
error(p, p.curr_tok.pos, "expected a selector")
|
||||||
advance_token(p)
|
operand = empty_selector_expr(tok, operand)
|
||||||
operand = ast.new(ast.Bad_Expr, operand.pos, end_pos(tok))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case .Arrow_Right:
|
case .Arrow_Right:
|
||||||
@@ -3361,8 +3371,7 @@ parse_atom_expr :: proc(p: ^Parser, value: ^ast.Expr, lhs: bool) -> (operand: ^a
|
|||||||
operand = sel
|
operand = sel
|
||||||
case:
|
case:
|
||||||
error(p, p.curr_tok.pos, "expected a selector")
|
error(p, p.curr_tok.pos, "expected a selector")
|
||||||
advance_token(p)
|
operand = empty_selector_expr(tok, operand)
|
||||||
operand = ast.new(ast.Bad_Expr, operand.pos, end_pos(tok))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case .Pointer:
|
case .Pointer:
|
||||||
|
|||||||
Reference in New Issue
Block a user