analyze: BlockContext has concept of module scope

This commit is contained in:
Andrew Kelley
2015-12-14 22:01:39 -07:00
parent 3049410260
commit 52e19b4a9b
5 changed files with 47 additions and 36 deletions

View File

@@ -2266,7 +2266,7 @@ static AstNode *ast_parse_struct_decl(ParseContext *pc, int *token_index) {
}
/*
TopLevelDecl : FnDef | ExternBlock | RootExportDecl | Use | StructDecl
TopLevelDecl : FnDef | ExternBlock | RootExportDecl | Use | StructDecl | VariableDeclaration
*/
static void ast_parse_top_level_decls(ParseContext *pc, int *token_index, ZigList<AstNode *> *top_level_decls) {
for (;;) {
@@ -2310,6 +2310,13 @@ static void ast_parse_top_level_decls(ParseContext *pc, int *token_index, ZigLis
}
pc->directive_list = nullptr;
AstNode *var_decl_node = ast_parse_variable_declaration_expr(pc, token_index, false);
if (var_decl_node) {
ast_eat_token(pc, token_index, TokenIdSemicolon);
top_level_decls->append(var_decl_node);
continue;
}
return;
}
zig_unreachable();