diff --git a/libcompiler/reader.scm b/libcompiler/reader.scm index afb8af1..bb4aeb4 100644 --- a/libcompiler/reader.scm +++ b/libcompiler/reader.scm @@ -1,6 +1,7 @@ #lang scheme/base (require scheme/list) +(require scheme/match) (require scheme/path) (provide read-module) @@ -14,17 +15,17 @@ (if (null? bindings) '() `((letrec ,(reverse bindings))))] - [`((define ,var ,expr) . ,rst) - (iter rst (cons (list var expr) bindings))] - [`((define (,var . ,arglist) . ,body) . ,rst) + [`((define (,(? symbol? var) . ,arglist) . ,body) . ,rst) (iter rst (cons (list var `(lambda ,arglist ,@body)) bindings))] + [`((define ,(? symbol? var) ,expr) . ,rst) + (iter rst (cons (list var expr) bindings))] [`((define . ,_) . ,_) (error "Unrecognized define-form:" (first forms))] [`((begin . ,body) . ,rst) (iter (append body rst) bindings)] [`((load ,(? string? pathname)) . ,rst) - (let ([complete-path (path->complete-path pathname)] - [directory (path-only complete-path)]) + (let* ([complete-path (path->complete-path pathname)] + [directory (path-only complete-path)]) (iter (append (with-input-from-file complete-path (lambda () (parameterize ([current-directory directory]) @@ -33,7 +34,7 @@ bindings))] [`((load . ,_) . ,rst) (error "Unrecognized load-form:" (first forms))] - [(,form . ,rst) + [`(,form . ,rst) (if (null? bindings) (cons form (iter rst '())) `((letrec ,(reverse bindings)