X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=jars.git;a=blobdiff_plain;f=parser.scm;h=c112cf9ccd9da9eda8b1d25ce9124374e6917260;hp=f1160337e1cd280d5ea1e62ed09b256fd2a903c2;hb=HEAD;hpb=6d7d7aac5eb776f36025d5c0b33d83e6bb1c6640 diff --git a/parser.scm b/parser.scm index f116033..b075e5a 100644 --- a/parser.scm +++ b/parser.scm @@ -15,7 +15,7 @@ (newline-irx (irregex "^\n")) (comma-irx (irregex "^,")) (period-irx (irregex "^\\.")) - (redcode-irx (irregex "^;redcode\n")) + (redcode-irx (irregex "^;redcode.*\n")) (name-start-irx (irregex "^;[ \t]*name ")) (name-irx (irregex "^[^\n]*")) (author-start-irx (irregex "^;[ \t]*author ")) @@ -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)