mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 08:47:35 +02:00
Emit sexp along with arg error
This commit is contained in:
parent
64c96545c1
commit
4300a759e3
1 changed files with 19 additions and 0 deletions
|
@ -2403,6 +2403,8 @@
|
|||
(expected-argc (length (ast:lambda-args lam)))
|
||||
(argc (- (length ast) 1)) )
|
||||
(when (not (= argc expected-argc))
|
||||
(compiler-msg "Compiler Error: ")
|
||||
(compiler-msg ast)
|
||||
(compiler-error
|
||||
"Expected "
|
||||
(number->string expected-argc)
|
||||
|
@ -2419,4 +2421,21 @@
|
|||
(newline (current-error-port))
|
||||
(exit 1))
|
||||
|
||||
;; Display a compilation message to the user
|
||||
(define (compiler-msg . sexp)
|
||||
(display (apply sexp->string sexp) (current-error-port))
|
||||
(newline (current-error-port)))
|
||||
|
||||
;; Convert given scheme expressions to a string, via (display)
|
||||
;; TODO: move to util module
|
||||
(define (sexp->string . sexps)
|
||||
(let ((p (open-output-string)))
|
||||
(for-each
|
||||
(lambda (sexp)
|
||||
(apply display (cons sexp (list p))))
|
||||
sexps)
|
||||
(let ((result (get-output-string p)))
|
||||
(close-port p)
|
||||
result)))
|
||||
|
||||
))
|
||||
|
|
Loading…
Add table
Reference in a new issue