Update parser for #sparse

This commit is contained in:
gingerBill
2022-02-06 11:50:27 +00:00
parent 19aec13a10
commit 0c16f27814

View File

@@ -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