aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-07-29 10:50:15 +0100
committergingerBill <bill@gingerbill.org>2018-07-29 10:50:15 +0100
commit6512a3e5f24a3aecb1451f921455a93231412104 (patch)
treee784404bf3ad291c54314e9ab9690e9bd9da754f /src/parser.cpp
parent49f2124df0f644e183f0570dd047493678eaf9f1 (diff)
using Foo :: enum {A, B, C}; len(Foo)
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index c2e0130ce..9d8e90347 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -920,11 +920,10 @@ Ast *ast_union_type(AstFile *f, Token token, Array<Ast *> variants, Ast *align)
}
-Ast *ast_enum_type(AstFile *f, Token token, Ast *base_type, bool is_export, Array<Ast *> fields) {
+Ast *ast_enum_type(AstFile *f, Token token, Ast *base_type, Array<Ast *> fields) {
Ast *result = alloc_ast_node(f, Ast_EnumType);
result->EnumType.token = token;
result->EnumType.base_type = base_type;
- result->EnumType.is_export = is_export;
result->EnumType.fields = fields;
return result;
}
@@ -1903,34 +1902,34 @@ Ast *parse_operand(AstFile *f, bool lhs) {
} break;
case Token_enum: {
- bool is_export = false;
+ // bool is_export = false;
Token token = expect_token(f, Token_enum);
Ast *base_type = nullptr;
if (f->curr_token.kind != Token_OpenBrace) {
if (f->curr_token.kind != Token_Hash) {
base_type = parse_type(f);
}
- while (allow_token(f, Token_Hash)) {
- Token tag = f->curr_token;
- if (!allow_token(f, Token_Ident) && !allow_token(f, Token_export)) {
- expect_token_after(f, Token_Ident, "#");
- }
- if (tag.string == "export") {
- if (is_export) {
- syntax_error(tag, "Duplicate enum tag '#%.*s'", LIT(tag.string));
- }
- is_export = true;
- } else {
- syntax_error(tag, "Invalid enum tag '#%.*s'", LIT(tag.string));
- }
- }
+ // while (allow_token(f, Token_Hash)) {
+ // Token tag = f->curr_token;
+ // if (!allow_token(f, Token_Ident) && !allow_token(f, Token_export)) {
+ // expect_token_after(f, Token_Ident, "#");
+ // }
+ // if (tag.string == "export") {
+ // if (is_export) {
+ // syntax_error(tag, "Duplicate enum tag '#%.*s'", LIT(tag.string));
+ // }
+ // is_export = true;
+ // } else {
+ // syntax_error(tag, "Invalid enum tag '#%.*s'", LIT(tag.string));
+ // }
+ // }
}
Token open = expect_token(f, Token_OpenBrace);
Array<Ast *> values = parse_element_list(f);
Token close = expect_token(f, Token_CloseBrace);
- return ast_enum_type(f, token, base_type, is_export, values);
+ return ast_enum_type(f, token, base_type, values);
} break;
case Token_bit_field: {
@@ -3591,10 +3590,10 @@ Ast *parse_stmt(AstFile *f) {
decl = parse_value_decl(f, list, docs);
if (decl != nullptr && decl->kind == Ast_ValueDecl) {
- if (!decl->ValueDecl.is_mutable) {
- syntax_error(token, "'using' may only be applied to variable declarations");
- return decl;
- }
+ // if (!decl->ValueDecl.is_mutable) {
+ // syntax_error(token, "'using' may only be applied to variable declarations");
+ // return decl;
+ // }
decl->ValueDecl.is_using = true;
return decl;
}