Fix
[c1cc.git] / c1cc / c1cc.lisp
blob0bd5fd62392f6dacb965b4d0ec8f526e36dc7355
1 (cl:defpackage #:c1cc
2 (:use #:cl #:c1))
4 (cl:in-package #:c1cc)
6 (defun read-file (&optional (stream *standard-input*))
7 (with-output-to-string (s)
8 (loop
9 do (let ((l (read-line stream nil nil)))
10 (unless l
11 (loop-finish))
12 (write-line l s)))))
14 (defvar *quit-on-error* t)
16 (defun c1cc-fake-debugger (condition foo)
17 (declare (ignore foo))
18 (format *error-output* "~&Error: ~A" condition)
19 (when *quit-on-error*
20 (let ((c (find-restart 'continue)))
21 (when c
22 (invoke-restart c))
23 #+ccl (ccl:quit)
24 #+sbcl (sb-ext:quit)
25 #+ecl (ext:quit))))
28 (defun main()
29 (eval-when (:load-toplevel :execute)
30 (let ((*debugger-hook* #'c1cc-fake-debugger))
31 (eir::write-asm
32 (c1::c1-eir-gencode
33 (c1::c1-parse (read-file)))))))
35 (defun fmain(filename)
36 (with-open-file (*standard-input* filename :direction :input)
37 (main)))
39 (defun fparse(filename)
40 (with-open-file (*standard-input* filename :direction :input)
41 (print (c1::c1-parse (read-file)))))