Skip to content

Commit

Permalink
Merge pull request #4 from cmsc430/crook
Browse files Browse the repository at this point in the history
crook
  • Loading branch information
dvanhorn authored Nov 20, 2024
2 parents c0bf972 + 3538829 commit 8b6393c
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion iniquity-plus/compile-ops.rkt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#lang racket
(provide compile-op0 compile-op1 compile-op2 compile-op3 pad-stack)
(provide compile-op0 compile-op1 compile-op2 compile-op3 pad-stack assert-cons)
(require "ast.rkt")
(require "types.rkt")
(require a86/ast)
Expand Down
14 changes: 14 additions & 0 deletions iniquity-plus/compile-stdin.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#lang racket
(provide main)
(require "parse.rkt")
(require "compile.rkt")
(require "read-all.rkt")
(require a86/printer)

;; -> Void
;; Compile contents of stdin,
;; emit asm code on stdout
(define (main)
(read-line) ; ignore #lang racket line
(asm-display (compile (apply parse (read-all)))))

1 change: 1 addition & 0 deletions iniquity-plus/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
(seq (Lea rax r)
(Push rax)
(compile-es es (cons #f c))
;; TODO: communicate argument count to called function
(Jmp (symbol->label f))
(Label r))))

Expand Down
13 changes: 13 additions & 0 deletions iniquity-plus/interp-stdin.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#lang racket
(provide main)
(require "parse.rkt")
(require "interp.rkt")
(require "read-all.rkt")

;; -> Void
;; Parse and interpret contents of stdin,
;; print result on stdout
(define (main)
(read-line) ; ignore #lang racket line
(println (interp (apply parse (read-all)))))

9 changes: 9 additions & 0 deletions iniquity-plus/read-all.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#lang racket
(provide read-all)
;; read all s-expression until eof
(define (read-all)
(let ((r (read)))
(if (eof-object? r)
'()
(cons r (read-all)))))

0 comments on commit 8b6393c

Please sign in to comment.