using in importation statements

This commit is contained in:
gingerBill
2017-12-17 11:17:54 +00:00
parent 1b6a14ac39
commit 0d665c637f
2 changed files with 108 additions and 31 deletions

View File

@@ -362,6 +362,7 @@ AST_NODE_KIND(_DeclBegin, "", i32) \
Token import_name; \
bool is_using; \
bool been_handled; \
Array<AstNode *> using_in_list; \
CommentGroup docs; \
CommentGroup comment; \
}) \
@@ -371,6 +372,7 @@ AST_NODE_KIND(_DeclBegin, "", i32) \
Token relpath; \
String fullpath; \
bool been_handled; \
Array<AstNode *> using_in_list; \
CommentGroup docs; \
CommentGroup comment; \
}) \
@@ -4518,6 +4520,25 @@ AstNode *parse_stmt(AstFile *f) {
return ast_bad_stmt(f, token, f->curr_token);
}
if (f->curr_token.kind == Token_in) {
Token in_token = expect_token(f, Token_in);
if (f->curr_token.kind == Token_import) {
AstNode *import_decl = parse_import_decl(f, true);
if (import_decl->kind == AstNode_ImportDecl) {
import_decl->ImportDecl.using_in_list = list;
}
return import_decl;
} else if (f->curr_token.kind == Token_export) {
AstNode *export_decl = parse_export_decl(f);
if (export_decl->kind == AstNode_ExportDecl) {
export_decl->ExportDecl.using_in_list = list;
}
return export_decl;
}
syntax_error(token, "Illegal use of 'using' statement");
return ast_bad_stmt(f, token, f->curr_token);
}
if (f->curr_token.kind != Token_Colon) {
expect_semicolon(f, list[list.count-1]);
return ast_using_stmt(f, token, list);