diff options
| author | Josh Wolfe <thejoshwolfe@gmail.com> | 2015-12-12 17:33:45 -0700 |
|---|---|---|
| committer | Josh Wolfe <thejoshwolfe@gmail.com> | 2015-12-12 17:33:45 -0700 |
| commit | 208258820108b1e921d456e99d48844ebbe91040 (patch) | |
| tree | 5d5f0da845b80920933d56396c6506c3d63017fa /src/parser.cpp | |
| parent | 64dd0b8d9535672484512a4a9957a63c08a32f3f (diff) | |
| download | zig-208258820108b1e921d456e99d48844ebbe91040.tar.gz zig-208258820108b1e921d456e99d48844ebbe91040.zip | |
fix short circuit expressions
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index 7b20bd7811..8b7ae50ae4 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -572,6 +572,7 @@ static void ast_invalid_token_error(ParseContext *pc, Token *token) { static AstNode *ast_parse_expression(ParseContext *pc, int *token_index, bool mandatory); static AstNode *ast_parse_block(ParseContext *pc, int *token_index, bool mandatory); static AstNode *ast_parse_if_expr(ParseContext *pc, int *token_index, bool mandatory); +static AstNode *ast_parse_block_expr(ParseContext *pc, int *token_index, bool mandatory); static void ast_expect_token(ParseContext *pc, Token *token, TokenId token_id) { if (token->id != token_id) { @@ -809,7 +810,7 @@ static AstNode *ast_parse_grouped_expr(ParseContext *pc, int *token_index, bool } /* -PrimaryExpression : token(Number) | token(String) | token(Unreachable) | GroupedExpression | token(Symbol) | Goto +PrimaryExpression : token(Number) | token(String) | KeywordLiteral | GroupedExpression | token(Symbol) | Goto | BlockExpression */ static AstNode *ast_parse_primary_expr(ParseContext *pc, int *token_index, bool mandatory) { Token *token = &pc->tokens->at(*token_index); @@ -864,6 +865,11 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc, int *token_index, bool return grouped_expr_node; } + AstNode *block_expr_node = ast_parse_block_expr(pc, token_index, false); + if (block_expr_node) { + return block_expr_node; + } + if (!mandatory) return nullptr; |
