aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-11-11 17:08:30 +0000
committergingerBill <bill@gingerbill.org>2018-11-11 17:08:30 +0000
commitb55b1ffe14bc4a7459cd9b9bdb8b9b0c8f7f8091 (patch)
tree77df172a7e387801f9f43999dcc412a6fb5b71be /src/parser.cpp
parent620d5d34f7c5712be27a92e1ab6ab48119f0a4c6 (diff)
`opaque` keyword and type
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 38678a6dc..e7181bfbb 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -80,6 +80,7 @@ Token ast_token(Ast *node) {
case Ast_TypeidType: return node->TypeidType.token;
case Ast_HelperType: return node->HelperType.token;
case Ast_DistinctType: return node->DistinctType.token;
+ case Ast_OpaqueType: return node->OpaqueType.token;
case Ast_PolyType: return node->PolyType.token;
case Ast_ProcType: return node->ProcType.token;
case Ast_PointerType: return node->PointerType.token;
@@ -319,6 +320,9 @@ Ast *clone_ast(Ast *node) {
case Ast_DistinctType:
n->DistinctType.type = clone_ast(n->DistinctType.type);
break;
+ case Ast_OpaqueType:
+ n->OpaqueType.type = clone_ast(n->OpaqueType.type);
+ break;
case Ast_ProcType:
n->ProcType.params = clone_ast(n->ProcType.params);
n->ProcType.results = clone_ast(n->ProcType.results);
@@ -849,6 +853,13 @@ Ast *ast_distinct_type(AstFile *f, Token token, Ast *type) {
return result;
}
+Ast *ast_opaque_type(AstFile *f, Token token, Ast *type) {
+ Ast *result = alloc_ast_node(f, Ast_OpaqueType);
+ result->OpaqueType.token = token;
+ result->OpaqueType.type = type;
+ return result;
+}
+
Ast *ast_poly_type(AstFile *f, Token token, Ast *type, Ast *specialization) {
Ast *result = alloc_ast_node(f, Ast_PolyType);
result->PolyType.token = token;
@@ -1654,6 +1665,12 @@ Ast *parse_operand(AstFile *f, bool lhs) {
return ast_distinct_type(f, token, type);
}
+ case Token_opaque: {
+ Token token = expect_token(f, Token_opaque);
+ Ast *type = parse_type(f);
+ return ast_opaque_type(f, token, type);
+ }
+
case Token_Hash: {
Token token = expect_token(f, Token_Hash);
Token name = expect_token(f, Token_Ident);