Skip to content

Commit

Permalink
Merge pull request #3 from cmsc430/crook
Browse files Browse the repository at this point in the history
Add Iniquity+ starter code
  • Loading branch information
dvanhorn authored Nov 14, 2024
2 parents 95ed25b + 6f7fd62 commit 7e28347
Show file tree
Hide file tree
Showing 15 changed files with 1,626 additions and 3 deletions.
65 changes: 65 additions & 0 deletions iniquity-plus/ast.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#lang racket
(provide Lit Prim0 Prim1 Prim2 Prim3 If Eof Begin
Let Var Prog Defn App
Apply FunPlain FunRest FunCase)

;; type Prog = (Prog (Listof Defn) Expr)
(struct Prog (ds e) #:prefab)

;; type Defn = (Defn Id Fun)
(struct Defn (f fun) #:prefab)

;; type Fun = (FunPlain [Listof Id] Expr)
;; | (FunRest [Listof Id] Id Expr)
;; | (FunCase [Listof FunCaseClause])
;; type FunCaseClause = (FunPlain [Listof Id] Expr)
;; | (FunRest [Listof Id] Id Expr)
(struct FunPlain (xs e) #:prefab)
(struct FunRest (xs x e) #:prefab)
(struct FunCase (cs) #:prefab)
;; type Expr = (Lit Datum)
;; | (Eof)
;; | (Prim0 Op0)
;; | (Prim1 Op1 Expr)
;; | (Prim2 Op2 Expr Expr)
;; | (Prim3 Op3 Expr Expr Expr)
;; | (If Expr Expr Expr)
;; | (Begin Expr Expr)
;; | (Let Id Expr Expr)
;; | (Var Id)
;; | (App Id (Listof Expr))
;; | (Apply Id (Listof Expr) Expr)

;; type Id = Symbol
;; type Datum = Integer
;; | Boolean
;; | Character
;; | String
;; type Op0 = 'read-byte | 'peek-byte | 'void
;; type Op1 = 'add1 | 'sub1
;; | 'zero?
;; | 'char? | 'integer->char | 'char->integer
;; | 'write-byte | 'eof-object?
;; | 'box | 'car | 'cdr | 'unbox
;; | 'empty? | 'cons? | 'box?
;; | 'vector? | 'vector-length
;; | 'string? | 'string-length
;; type Op2 = '+ | '- | '< | '=
;; | 'eq? | 'cons
;; | 'make-vector | 'vector-ref
;; | 'make-string | 'string-ref
;; type Op3 = 'vector-set!

(struct Eof () #:prefab)
(struct Lit (d) #:prefab)
(struct Prim0 (p) #:prefab)
(struct Prim1 (p e) #:prefab)
(struct Prim2 (p e1 e2) #:prefab)
(struct Prim3 (p e1 e2 e3) #:prefab)
(struct If (e1 e2 e3) #:prefab)
(struct Begin (e1 e2) #:prefab)
(struct Let (x e1 e2) #:prefab)
(struct Var (x) #:prefab)
(struct App (f es) #:prefab)
(struct Apply (f es e) #:prefab)

14 changes: 14 additions & 0 deletions iniquity-plus/build-runtime.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#lang racket
(provide runtime-path)

(require racket/runtime-path)
(define-runtime-path here ".")

(unless (system (string-append "make -C '"
(path->string (normalize-path here))
"' -s runtime.o"))
(error 'build-runtime "could not build runtime"))

(define runtime-path
(normalize-path (build-path here "runtime.o")))

Loading

0 comments on commit 7e28347

Please sign in to comment.