forked from ParkerTewell/Typed-Iniquity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.rkt~
66 lines (60 loc) · 1.98 KB
/
ast.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#lang racket
(provide (all-defined-out))
;; type Prog = (Prog (Listof Defn) (Listof TypeDefn) Expr)
(struct Prog (ds tds e) #:prefab)
;; type Defn = (Defn Id (Listof Id) Expr)
(struct Defn (f xs e) #:prefab)
;; type TypeDefn = (TypeDefn Id (Listof Type) Type)
(struct TypeDefn (f tsx te) #:prefab)
;; type Expr = (Eof)
;; | (Empty)
;; | (Int Integer)
;; | (Bool Boolean)
;; | (Char Character)
;; | (Str String)
;; | (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))
;; type Id = Symbol
;; type Op0 = 'read-byte
;; 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 = '+ | '- | '< | '=
;; | 'cons
;; | 'make-vector | 'vector-ref
;; | 'make-string | 'string-ref
;; type Op3 = 'vector-set!
;; type Type = TAny
;; | TInt
;; | TBool
;; | TChar
;; | TStr
;; | TList
;; | (TUnion Type Type)
(struct Eof () #:prefab)
(struct Empty () #:prefab)
(struct Int (i) #:prefab)
(struct Bool (b) #:prefab)
(struct Char (c) #:prefab)
(struct Str (s) #: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 TUnion (t1 t2) #:prefab)