commit f0d14dd58d4124cc7ec695a8fa7631bca1385a6f
parent 851ae9124493230ca2ca1f9ab767747701d615d2
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Sat, 29 Jan 2022 10:31:30 -0600
parse: only accept curly brackets for blocks that aren't the toplevel
Diffstat:
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/parse.c b/parse.c
@@ -374,20 +374,20 @@ static void
parseblock(struct block *const block)
{
struct statement statement;
- bool curlies = false, toplevel_decl = blockpeek() == NULL;
+ bool toplevel = blockpeek() == NULL;
blockpush(block);
- if (tok->type == TOK_LCURLY) {
- curlies = true;
+ if (!toplevel) {
+ expect(TOK_LCURLY);
tok = tok->next;
}
- while (!(tok->type == TOK_NONE || (curlies && tok->type == TOK_RCURLY))) {
+ while (!(tok->type == TOK_NONE || (!toplevel && tok->type == TOK_RCURLY))) {
statement = (struct statement){ 0 };
statement.start = tok;
if (tok->type == TOK_LET) {
struct decl decl = { 0 };
- decl.toplevel = toplevel_decl;
+ decl.toplevel = toplevel;
decl.start = tok;
statement.kind = STMT_DECL;
tok = tok->next;
@@ -431,7 +431,7 @@ parseblock(struct block *const block)
}
}
- if (curlies) {
+ if (!toplevel) {
expect(TOK_RCURLY);
tok = tok->next;
}
diff --git a/test/curly2.fail.nooc b/test/curly2.fail.nooc
@@ -0,0 +1 @@
+let main proc() = proc() syscall2(60, 0)+
\ No newline at end of file