+++ /dev/null
-(import (chicken irregex))
-
-(define (string->instr str)
- (let ((idx 0)
- (l (string-length str))
- (whitespace-irx (irregex "[ \t]*"))
- (newline-irx (irregex "\n"))
- (comment-irx (irregex ";[^\n]*")))
- (define (accept-token irx mandatory)
- (let ((wsmatch (irregex-match whitespace-irx (substr str idx))))
- (set! idx (+ idx (irregex-match-end-index wsmatch)))) ;Skip leading whitespace
- (let ((res (irregex-match irx (substring str idx))))
- (if res
- (begin
- (set! idx (+ idx (irregex-match-end-index res)))
- (irregex-match-substring res))
- (if mandatory
- (error "Unexpected token at input string index" idx)
- #f))))
- (define (accept-token-string token-str mandatory)
- (accept-token (irregex token-str) mandatory))
- (define (load-file)
- (let loop ()
- (if (line)
- (loop))))
- (define (line)
- (or (accept-token comment-irx #f)
- (accept-token newline-irx #f)
- (and(accept-token newline-irx #t))))
- (define (instruction)
- (and (opcode)
- (accept-token period-irx #t)
- (accept-modifier)))))
-