aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-02-24 19:03:29 +0000
committergingerBill <bill@gingerbill.org>2018-02-24 19:03:29 +0000
commit35ba5771a5dbe5fec3fea8804fb46fe843478830 (patch)
treed46c33864d8a2b14a2bba7c860ce2cf875f2bc39 /src/parser.cpp
parentb2461f7192684f979301be9f174237e740ec28c6 (diff)
Replace `compile_assert` with `#assert`
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index f05f9a0e1..182576913 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1659,6 +1659,9 @@ AstNode *parse_operand(AstFile *f, bool lhs) {
} else if (name.string == "location") {
AstNode *tag = ast_basic_directive(f, token, name.string);
return parse_call_expr(f, tag);
+ } else if (name.string == "assert") {
+ AstNode *tag = ast_basic_directive(f, token, name.string);
+ return parse_call_expr(f, tag);
} else {
operand = ast_tag_expr(f, token, name, parse_expr(f, false));
}
@@ -3735,6 +3738,9 @@ AstNode *parse_stmt(AstFile *f) {
break;
}
return s;
+ } else if (tag == "assert") {
+ AstNode *t = ast_basic_directive(f, hash_token, tag);
+ return parse_call_expr(f, t);
}
if (tag == "include") {
@@ -4058,6 +4064,14 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, Array<AstNod
node->kind != AstNode_EmptyStmt &&
node->kind != AstNode_WhenStmt) {
// NOTE(bill): Sanity check
+
+ if (node->kind == AstNode_CallExpr &&
+ node->CallExpr.proc->kind == AstNode_BasicDirective &&
+ node->CallExpr.proc->BasicDirective.name == "assert") {
+ // NOTE(bill): Okay!
+ continue;
+ }
+
syntax_error(node, "Only declarations are allowed at file scope, got %.*s", LIT(ast_node_strings[node->kind]));
} else if (node->kind == AstNode_ImportDecl) {
ast_node(id, ImportDecl, node);