From d82e1615b58bf59f1d8b14dd62c588be6ea1881c Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Sat, 27 Jul 2024 10:09:50 +0000 Subject: [PATCH] Skip empty lines in parseprog --- parse.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/parse.c b/parse.c index 55c20fe..81be21e 100644 --- a/parse.c +++ b/parse.c @@ -159,14 +159,22 @@ parseprog(TokenList *t) prog->tag = AstProg; while(peek(t) != TokEnd){ - Ast *child; - if(peek(t) == TokDel) + Ast *child = nil; + switch(peek(t)){ + case TokDiamond: + case TokNewline: + break; + case TokDel: child = parsefuncdef(t); - else + break; + default: child = parseexpr(t, nil, nil); + break; + } if(peek(t) != TokEnd) parseseps(t, 1); - addchild(prog, child); + if(child) + addchild(prog, child); } return prog; } -- 2.45.2