aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-09-09 23:33:54 +0100
committerGinger Bill <bill@gingerbill.org>2016-09-09 23:33:54 +0100
commit6979678ff947cecc8e6e0d0e8ceea7e0304d3f4e (patch)
tree774b9480272eba57e1a09011107cc136b43dde65 /src/parser.cpp
parent1ca752ce049b934df5d03af2f06265e219f5f402 (diff)
Begin reording of struct members by default.
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 17c15c890..bd98e8c1e 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -245,6 +245,7 @@ AST_NODE_KIND(_TypeBegin, "", struct{}) \
AstNodeArray decls; \
isize decl_count; \
b32 is_packed; \
+ b32 is_ordered; \
}) \
AST_NODE_KIND(UnionType, "union type", struct { \
Token token; \
@@ -815,12 +816,13 @@ 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, AstNodeArray decls, isize decl_count, b32 is_packed) {
+gb_inline AstNode *make_struct_type(AstFile *f, Token token, AstNodeArray decls, isize decl_count, b32 is_packed, b32 is_ordered) {
AstNode *result = make_node(f, AstNode_StructType);
result->StructType.token = token;
result->StructType.decls = decls;
result->StructType.decl_count = decl_count;
result->StructType.is_packed = is_packed;
+ result->StructType.is_ordered = is_ordered;
return result;
}
@@ -1826,12 +1828,15 @@ AstNode *parse_identifier_or_type(AstFile *f) {
case Token_struct: {
Token token = expect_token(f, Token_struct);
b32 is_packed = false;
- if (allow_token(f, Token_Hash)) {
+ b32 is_ordered = false;
+ while (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");
+ } else if (are_strings_equal(tag.string, make_string("ordered"))) {
+ is_ordered = true;
+ } else {
+ ast_file_err(f, tag, "Expected a `#packed` or `#ordered` tag");
}
}
@@ -1840,7 +1845,7 @@ AstNode *parse_identifier_or_type(AstFile *f) {
AstNodeArray decls = parse_struct_params(f, &decl_count, true);
Token close = expect_token(f, Token_CloseBrace);
- return make_struct_type(f, token, decls, decl_count, is_packed);
+ return make_struct_type(f, token, decls, decl_count, is_packed, is_ordered);
} break;
case Token_union: {