3 (include "pic18-sim.scm")
4 (include "utilities.scm")
6 (include "operators.scm")
10 (include "optimizations.scm")
11 (include "code-generation.scm")
14 ;------------------------------------------------------------------------------
16 (define (read-source filename)
17 (shell-command (string-append "cpp -P " filename " > " filename ".tmp"))
18 ;; (##read-all-as-a-begin-expr-from-path ;; TODO use vectorized notation to have info on errors (where in the source)
19 ;; (string-append filename ".tmp")
20 ;; (readtable-start-syntax-set (current-readtable) 'six)
24 (string-append filename ".tmp")
26 (input-port-readtable-set!
28 (readtable-start-syntax-set
29 (input-port-readtable (current-input-port))
34 (define (main filename)
36 (output-port-readtable-set!
38 (readtable-sharing-allowed?-set
39 (output-port-readtable (current-output-port))
42 (let ((source (read-source filename)))
44 (let ((ast (parse source)))
46 (let ((cfg (generate-cfg ast)))
49 (remove-branch-cascades-and-dead-code cfg)
50 (remove-converging-branches cfg)
51 (remove-dead-instructions cfg)
55 (let ((code (code-gen filename cfg)))
57 '(display "------------------ EXECUTION USING SIMULATOR\n")
58 (execute-hex-file (string-append filename ".hex")))))))