The Lambda Lab
/
projects
/
jars.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added parse error on empty program.
[jars.git]
/
parser.scm
diff --git
a/parser.scm
b/parser.scm
index
f116033
..
b075e5a
100644
(file)
--- a/
parser.scm
+++ b/
parser.scm
@@
-15,7
+15,7
@@
(newline-irx (irregex "^\n"))
(comma-irx (irregex "^,"))
(period-irx (irregex "^\\."))
(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 "))
(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)
(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)
(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)))
((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)
(define (line)
(or (name-line)