-
Notifications
You must be signed in to change notification settings - Fork 0
/
mips.rkt
31 lines (27 loc) · 782 Bytes
/
mips.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#lang racket/base
(require "parser.rkt"
"compiler.rkt"
"ast.rkt")
(define argv (current-command-line-arguments))
(cond
((= (vector-length argv) 1)
(define in (open-input-file (vector-ref argv 0)))
(define program (program_parser in))
(newline)
(data)
(mips-data (make-hash '((t . "\nTrue\n")(f . "\nFalse\n") )))
(mips-data (make-hash '((newline . "\n"))))
(define envrmnt (make-immutable-hash))
(data-eval program envrmnt)
(newline)
(text)
(mips-function program envrmnt)
(newline)
(main)
(program-eval program envrmnt)
(mips-exit)
(close-input-port in))
(else
(eprintf "Usage: racket pymips.rkt <source.py>\n")
;;(eprintf "Usage: racket mips.rkt \"program\"\n")
(exit 1)))