aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-12-02 18:01:03 +0000
committergingerBill <bill@gingerbill.org>2018-12-02 18:01:03 +0000
commit28583bfff88ff1378a0e71030701071dcfd37462 (patch)
tree6d3594ed87f0e1a364f25589ee5c1d8aef820f4a /src
parentb2df48dadbc3382fec81f9da0e42d5a0c7be7fff (diff)
Change procedure group syntax from `proc[]` to `proc{}`; deprecate `proc[]` (raises warning currently)
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp4
-rw-r--r--src/parser.cpp25
2 files changed, 26 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 5f23615d0..86ff4f0cd 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -6543,12 +6543,12 @@ gbString write_expr_to_string(gbString str, Ast *node) {
case_end;
case_ast_node(pg, ProcGroup, node);
- str = gb_string_appendc(str, "proc[");
+ str = gb_string_appendc(str, "proc{");
for_array(i, pg->args) {
if (i > 0) str = gb_string_appendc(str, ", ");
str = write_expr_to_string(str, pg->args[i]);
}
- str = gb_string_append_rune(str, ']');
+ str = gb_string_append_rune(str, '}');
case_end;
case_ast_node(pl, ProcLit, node);
diff --git a/src/parser.cpp b/src/parser.cpp
index e64c42ed5..bce0260cb 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1742,8 +1742,31 @@ Ast *parse_operand(AstFile *f, bool lhs) {
case Token_proc: {
Token token = expect_token(f, Token_proc);
- if (f->curr_token.kind == Token_OpenBracket) { // ProcGroup
+ if (f->curr_token.kind == Token_OpenBrace) { // ProcGroup
+ Token open = expect_token(f, Token_OpenBrace);
+
+ auto args = array_make<Ast *>(heap_allocator());
+
+ while (f->curr_token.kind != Token_CloseBrace &&
+ f->curr_token.kind != Token_EOF) {
+ Ast *elem = parse_expr(f, false);
+ array_add(&args, elem);
+
+ if (!allow_token(f, Token_Comma)) {
+ break;
+ }
+ }
+
+ Token close = expect_token(f, Token_CloseBrace);
+
+ if (args.count == 0) {
+ syntax_error(token, "Expected a least 1 argument in a procedure group");
+ }
+
+ return ast_proc_group(f, token, open, close, args);
+ } else if (f->curr_token.kind == Token_OpenBracket) { // ProcGroup
Token open = expect_token(f, Token_OpenBracket);
+ warning(open, "Procedure groups using [] are now deprecated, please use {} instead");
auto args = array_make<Ast *>(heap_allocator());