Add file for AST

This commit is contained in:
Yiyun Liu 2025-05-24 13:21:15 -04:00
parent 7776723a77
commit 1507c6c40f

19
ast.rkt Normal file
View file

@ -0,0 +1,19 @@
#lang typed/racket
(define-type ConId Integer)
(define-type Arity Integer)
(define-type Let ( 'let 'letrec))
(define-type Name Symbol)
(define-type (Bind A) (List A (Expr A)))
(define-type (Alt A) (List 'branch ConId (Listof A) (Expr A)))
(define-type (Expr A)
( Name
Integer
(List 'pack ConId Arity)
(List (Expr A) (Expr A))
(List Let (Pair (Bind A) (Listof (Bind A))) (Expr A))
(List 'case (Expr A) (Pair (Alt A) (Listof (Alt A))))
(List 'λ (Pair Name (Listof Name)) (Expr A))))