mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +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
|
return original_type
|
||||||
|
|
||||||
case "partial":
|
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 := ast.new(ast.Basic_Directive, tok.pos, end_pos(name))
|
||||||
tag.tok = tok
|
tag.tok = tok
|
||||||
tag.name = name.text
|
tag.name = name.text
|
||||||
|
|||||||
Reference in New Issue
Block a user