shithub: lpa

Download patch

ref: d82e1615b58bf59f1d8b14dd62c588be6ea1881c
parent: a062a0574fa9bbff7f3cb62251b41d42a441440f
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Sat Jul 27 06:09:50 EDT 2024

Skip empty lines in parseprog

--- a/parse.c
+++ b/parse.c
@@ -159,14 +159,22 @@
 	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;
 }