aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-01-23 23:30:20 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-01-23 23:30:20 -0500
commit32d8686da80d282e8cd6d84a0e5c331d269a1f69 (patch)
tree889c1f634f4ff2e7b9d8cb078f11dbb41c4a1b2a /src/parser.cpp
parent17cb85dfb837949cd3a559fe8e99dee1f72463a4 (diff)
downloadzig-32d8686da80d282e8cd6d84a0e5c331d269a1f69.tar.gz
zig-32d8686da80d282e8cd6d84a0e5c331d269a1f69.zip
various fixes
* comptime expression is a block expression as it should be * fix var args when number of args passed is 0 * implement const value equality for structs * fix indent when rendering container decl AST * IR: prevent duplicate generation of code when it is partially compile-time evaluated * implement compile time struct field pointer evaluation * fix compile time evaluation of slicing
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 04c31fcfe0..02926db46a 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -624,7 +624,7 @@ static AstNode *ast_parse_comptime_expr(ParseContext *pc, size_t *token_index, b
}
/*
-PrimaryExpression = Number | String | CharLiteral | KeywordLiteral | GroupedExpression | GotoExpression | CompTimeExpression | BlockExpression | Symbol | ("@" Symbol FnCallExpression) | ArrayType | (option("extern") FnProto) | AsmExpression | ("error" "." Symbol) | ContainerDecl
+PrimaryExpression = Number | String | CharLiteral | KeywordLiteral | GroupedExpression | GotoExpression | BlockExpression | Symbol | ("@" Symbol FnCallExpression) | ArrayType | (option("extern") FnProto) | AsmExpression | ("error" "." Symbol) | ContainerDecl
KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this"
*/
static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
@@ -709,10 +709,6 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bo
if (goto_node)
return goto_node;
- AstNode *comptime_node = ast_parse_comptime_expr(pc, token_index, false);
- if (comptime_node)
- return comptime_node;
-
AstNode *grouped_expr_node = ast_parse_grouped_expr(pc, token_index, false);
if (grouped_expr_node) {
return grouped_expr_node;
@@ -1810,7 +1806,7 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo
}
/*
-BlockExpression : IfExpression | Block | WhileExpression | ForExpression | SwitchExpression
+BlockExpression = IfExpression | Block | WhileExpression | ForExpression | SwitchExpression | CompTimeExpression
*/
static AstNode *ast_parse_block_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
Token *token = &pc->tokens->at(*token_index);
@@ -1835,6 +1831,10 @@ static AstNode *ast_parse_block_expr(ParseContext *pc, size_t *token_index, bool
if (block)
return block;
+ AstNode *comptime_node = ast_parse_comptime_expr(pc, token_index, false);
+ if (comptime_node)
+ return comptime_node;
+
if (mandatory)
ast_invalid_token_error(pc, token);