fisl

fisl is scheme lox
git clone git://git.alexkarle.com.com/fisl
Log | Files | Refs | README | LICENSE

commit 9b0ba684a64cf7ea6f516865ef923c4697c68b0c (patch)
parent 7dc01d44885e76321bcbd135e03d3e8f84cf8c30
Author: Alex Karle <alex@alexkarle.com>
Date:   Thu, 17 Nov 2022 12:14:34 -0500

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!

Diffstat:
Mparser.scm | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 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))) '())))