mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 09:54:45 +00:00
using in importation statements
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user