3 (include "pic18-sim.scm")
4 (include "utilities.scm")
6 (include "operators.scm")
10 (include "optimizations.scm")
11 (include "code-generation.scm")
14 ;------------------------------------------------------------------------------
16 ;; temporary solution, to support more than int
17 (set! ##six-types ;; TODO signed types ?
29 ;; TODO typedef should add to this list
31 (define (read-source filename)
32 (shell-command (string-append "cpp -P " filename " > " filename ".tmp"))
33 ;; (##read-all-as-a-begin-expr-from-path ;; TODO use vectorized notation to have info on errors (where in the source)
34 ;; (string-append filename ".tmp")
35 ;; (readtable-start-syntax-set (current-readtable) 'six)
39 (string-append filename ".tmp")
41 (input-port-readtable-set!
43 (readtable-start-syntax-set
44 (input-port-readtable (current-input-port))
49 (define (main filename)
51 (output-port-readtable-set!
53 (readtable-sharing-allowed?-set
54 (output-port-readtable (current-output-port))
57 (let ((source (read-source filename)))
58 '(pretty-print source)
59 (let* ((ast (parse source)))
61 (let ((cfg (generate-cfg ast)))
64 (remove-branch-cascades-and-dead-code cfg)
65 (remove-converging-branches cfg)
66 (remove-dead-instructions cfg)
70 (let ((code (code-gen filename cfg)))
72 '(display "------------------ GENERATED CODE\n")
73 (asm-display-listing (current-output-port))
74 (asm-write-hex-file (string-append filename ".hex"))
76 '(display "------------------ EXECUTION USING SIMULATOR\n")
77 (execute-hex-file (string-append filename ".hex"))