diff options
| author | gingerBill <bill+github@gingerbill.org> | 2016-08-10 11:53:17 +0100 |
|---|---|---|
| committer | gingerBill <bill+github@gingerbill.org> | 2016-08-10 11:53:17 +0100 |
| commit | 153c27c7556ebef0c98055d87937b942d198f629 (patch) | |
| tree | bdb5b61a78e4eed8f232a808a74fad480330529e /src/parser.cpp | |
| parent | c930841f834e43df28be41e8e3509773a523ed0f (diff) | |
Tuple support in codegen
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 43d3cf196..ec4918430 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -206,6 +206,7 @@ AST_NODE_KIND(_TypeBegin, struct{}) \ Token token; \ AstNode *field_list; \ isize field_count; \ + b32 is_packed; \ }) \ AST_NODE_KIND(_TypeEnd, struct{}) \ AST_NODE_KIND(Count, struct{}) @@ -740,11 +741,12 @@ gb_inline AstNode *make_vector_type(AstFile *f, Token token, AstNode *count, Ast return result; } -gb_inline AstNode *make_struct_type(AstFile *f, Token token, AstNode *field_list, isize field_count) { +gb_inline AstNode *make_struct_type(AstFile *f, Token token, AstNode *field_list, isize field_count, b32 is_packed) { AstNode *result = make_node(f, AstNode_StructType); result->StructType.token = token; result->StructType.field_list = field_list; result->StructType.field_count = field_count; + result->StructType.is_packed = is_packed; return result; } @@ -1491,12 +1493,21 @@ AstNode *parse_identifier_or_type(AstFile *f) { AstNode *params = NULL; isize param_count = 0; AstScope *scope = make_ast_scope(f, NULL); // NOTE(bill): The struct needs its own scope with NO parent + b32 is_packed = false; + if (allow_token(f, Token_Hash)) { + Token tag = expect_token(f, Token_Identifier); + if (are_strings_equal(tag.string, make_string("packed"))) { + is_packed = true; + } else { + ast_file_err(f, tag, "Expected a `#packed` tag"); + } + } open = expect_token(f, Token_OpenBrace); params = parse_parameter_list(f, scope, ¶m_count); close = expect_token(f, Token_CloseBrace); - return make_struct_type(f, token, params, param_count); + return make_struct_type(f, token, params, param_count, is_packed); } case Token_proc: |