mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-03 19:44:42 +00:00
Update parser for #sparse
This commit is contained in:
@@ -2273,6 +2273,24 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
return original_type
|
||||
|
||||
case "partial":
|
||||
tag := ast.new(ast.Basic_Directive, tok.pos, end_pos(name))
|
||||
tag.tok = tok
|
||||
tag.name = name.text
|
||||
original_expr := parse_expr(p, lhs)
|
||||
expr := ast.unparen_expr(original_expr)
|
||||
switch t in &expr.derived {
|
||||
case ast.Comp_Lit:
|
||||
t.tag = tag
|
||||
case ast.Array_Type:
|
||||
t.tag = tag
|
||||
error(p, tok.pos, "#%s has been replaced with #sparse for non-contiguous enumerated array types", name.text)
|
||||
case:
|
||||
error(p, tok.pos, "expected a compound literal after #%s", name.text)
|
||||
|
||||
}
|
||||
return original_expr
|
||||
|
||||
case "sparse":
|
||||
tag := ast.new(ast.Basic_Directive, tok.pos, end_pos(name))
|
||||
tag.tok = tok
|
||||
tag.name = name.text
|
||||
|
||||
Reference in New Issue
Block a user