mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 20:58:15 +00:00
Remove bit_field keyword and parsing logic
This commit is contained in:
@@ -713,15 +713,6 @@ Enum_Type :: struct {
|
||||
is_using: bool,
|
||||
}
|
||||
|
||||
Bit_Field_Type :: struct {
|
||||
using node: Expr,
|
||||
tok_pos: tokenizer.Pos,
|
||||
align: ^Expr,
|
||||
open: tokenizer.Pos,
|
||||
fields: []^Field_Value, // Field_Value with ':' rather than '='
|
||||
close: tokenizer.Pos,
|
||||
}
|
||||
|
||||
Bit_Set_Type :: struct {
|
||||
using node: Expr,
|
||||
tok_pos: tokenizer.Pos,
|
||||
|
||||
@@ -269,8 +269,6 @@ clone_node :: proc(node: ^Node) -> ^Node {
|
||||
case Enum_Type:
|
||||
r.base_type = clone(r.base_type);
|
||||
r.fields = clone(r.fields);
|
||||
case Bit_Field_Type:
|
||||
r.fields = clone(r.fields);
|
||||
case Bit_Set_Type:
|
||||
r.elem = clone(r.elem);
|
||||
r.underlying = clone(r.underlying);
|
||||
|
||||
@@ -387,13 +387,6 @@ walk :: proc(v: ^Visitor, node: ^Node) {
|
||||
walk(v, n.base_type);
|
||||
}
|
||||
walk_expr_list(v, n.fields);
|
||||
case Bit_Field_Type:
|
||||
if n.align != nil {
|
||||
walk(v, n.align);
|
||||
}
|
||||
for x in n.fields {
|
||||
walk(v, x);
|
||||
}
|
||||
case Bit_Set_Type:
|
||||
walk(v, n.elem);
|
||||
if n.underlying != nil {
|
||||
|
||||
@@ -415,7 +415,7 @@ is_semicolon_optional_for_node :: proc(p: ^Parser, node: ^ast.Node) -> bool {
|
||||
return is_semicolon_optional_for_node(p, n.type);
|
||||
case ast.Pointer_Type:
|
||||
return is_semicolon_optional_for_node(p, n.elem);
|
||||
case ast.Struct_Type, ast.Union_Type, ast.Enum_Type, ast.Bit_Field_Type:
|
||||
case ast.Struct_Type, ast.Union_Type, ast.Enum_Type:
|
||||
// Require semicolon within a procedure body
|
||||
return p.curr_proc == nil;
|
||||
case ast.Proc_Lit:
|
||||
@@ -2538,59 +2538,6 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr {
|
||||
et.close = close.pos;
|
||||
return et;
|
||||
|
||||
case .Bit_Field:
|
||||
tok := expect_token(p, .Bit_Field);
|
||||
|
||||
fields: [dynamic]^ast.Field_Value;
|
||||
align: ^ast.Expr;
|
||||
|
||||
prev_level := p.expr_level;
|
||||
p.expr_level = -1;
|
||||
|
||||
for allow_token(p, .Hash) {
|
||||
tag := expect_token_after(p, .Ident, "#");
|
||||
switch tag.text {
|
||||
case "align":
|
||||
if align != nil {
|
||||
error(p, tag.pos, "duplicate bit_field tag '#%s", tag.text);
|
||||
}
|
||||
align = parse_expr(p, true);
|
||||
case:
|
||||
error(p, tag.pos, "invalid bit_field tag '#%s", tag.text);
|
||||
}
|
||||
}
|
||||
|
||||
p.expr_level = prev_level;
|
||||
|
||||
open := expect_token_after(p, .Open_Brace, "bit_field");
|
||||
|
||||
for p.curr_tok.kind != .Close_Brace && p.curr_tok.kind != .EOF {
|
||||
name := parse_ident(p);
|
||||
colon := expect_token(p, .Colon);
|
||||
value := parse_expr(p, true);
|
||||
|
||||
fv := ast.new(ast.Field_Value, name.pos, value.end);
|
||||
fv.field = name;
|
||||
fv.sep = colon.pos;
|
||||
fv.value = value;
|
||||
append(&fields, fv);
|
||||
|
||||
if !allow_token(p, .Comma) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
close := expect_token(p, .Close_Brace);
|
||||
|
||||
bft := ast.new(ast.Bit_Field_Type, tok.pos, end_pos(close));
|
||||
bft.tok_pos = tok.pos;
|
||||
bft.open = open.pos;
|
||||
bft.fields = fields[:];
|
||||
bft.close = close.pos;
|
||||
bft.align = align;
|
||||
|
||||
return bft;
|
||||
|
||||
case .Bit_Set:
|
||||
tok := expect_token(p, .Bit_Set);
|
||||
open := expect_token(p, .Open_Bracket);
|
||||
@@ -2719,7 +2666,6 @@ is_literal_type :: proc(expr: ^ast.Expr) -> bool {
|
||||
ast.Enum_Type,
|
||||
ast.Dynamic_Array_Type,
|
||||
ast.Map_Type,
|
||||
ast.Bit_Field_Type,
|
||||
ast.Bit_Set_Type,
|
||||
ast.Call_Expr:
|
||||
return true;
|
||||
|
||||
@@ -134,7 +134,6 @@ Token_Kind :: enum u32 {
|
||||
Struct, // struct
|
||||
Union, // union
|
||||
Enum, // enum
|
||||
Bit_Field, // bit_field
|
||||
Bit_Set, // bit_set
|
||||
Map, // map
|
||||
Dynamic, // dynamic
|
||||
@@ -261,7 +260,6 @@ tokens := [Token_Kind.COUNT]string {
|
||||
"struct",
|
||||
"union",
|
||||
"enum",
|
||||
"bit_field",
|
||||
"bit_set",
|
||||
"map",
|
||||
"dynamic",
|
||||
|
||||
Reference in New Issue
Block a user