From: plugd Date: Thu, 9 Mar 2023 14:04:19 +0000 (+0100) Subject: Added parse error on empty program. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=jars.git Added parse error on empty program. --- diff --git a/parser.scm b/parser.scm index c112cf9..b075e5a 100644 --- a/parser.scm +++ b/parser.scm @@ -75,8 +75,8 @@ (accept-token redcode-irx #t) (let loop ((instrs '()) (offset 0) - (name '()) - (author '())) + (name #f) + (author "Unspecified")) (let ((this-line (line))) (if this-line (case (car this-line) @@ -85,7 +85,10 @@ ((comment) (loop instrs offset name author)) ((org) (loop instrs (cdr this-line) name author)) ((instr) (loop (cons (cdr this-line) instrs) offset name author))) - (make-prog name author (reverse instrs) offset))))) + (begin + (if (and name (not (null? instrs))) + (make-prog name author (reverse instrs) offset) + (error "Failed to parse name and/or instructions"))))))) (define (line) (or (name-line)