From 52e19b4a9b6e6140bae3c20c6f1fef36dca20aa7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 14 Dec 2015 22:01:39 -0700 Subject: analyze: BlockContext has concept of module scope --- src/parser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index bb75a0da6e..280f8da4d7 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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 *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(); -- cgit v1.2.3