From 9b0ba684a64cf7ea6f516865ef923c4697c68b0c Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Thu, 17 Nov 2022 12:14:34 -0500 Subject: [PATCH] parser: Fix synchronization at end of input In Scheme, only #f is falsey: > (if 0 (print "truthy")) truthy > (if '() (print "truthy")) truthy So checking (and toks ...) wasn't doing the empty list check I was intending! --- parser.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser.scm b/parser.scm index 6fc576e..d71e991 100644 --- a/parser.scm +++ b/parser.scm @@ -181,7 +181,7 @@ ;; Loop through declarations, starting with tokens BUT using call/cc ;; to bookmark the loop so we can synchronize on parse-err! (let loop ((toks (call/cc (lambda (cc) (set! parser-sync cc) tokens)))) - (if (and toks (not (top-type? toks '(EOF)))) + (if (and (not (null? toks)) (not (top-type? toks '(EOF)))) (let-values (((expr rest) (parse-declaration toks))) (cons expr (loop rest))) '()))) -- libgit2 1.1.1