Created
October 22, 2024 12:39
-
-
Save SHoltzen/5911d50fba9375aab09974e73861d323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; part 1 | |
;;; do not modify anything in this file except for interp and type-check?. You | |
;;; are permitted to add your own helper functions, structs, etc. | |
#lang racket | |
(require rackunit) | |
(define (eveclang? e) | |
(or (elet? e) (evec? e) (egetvec? e) (enum? e) (eident? e))) | |
;;; do not change these structs | |
(struct elet (id assgn body) #:transparent | |
#:guard (struct-guard/c string? eveclang? eveclang?)) | |
(struct eident (id) #:transparent | |
#:guard (struct-guard/c string?)) | |
(struct evec (l) #:transparent | |
#:guard (struct-guard/c (listof integer?))) | |
(struct enum (n) #:transparent | |
#:guard (struct-guard/c integer?)) | |
(struct egetvec (e idx) #:transparent | |
#:guard (struct-guard/c eveclang? integer?)) | |
;;; declare a type exception that is a subtype of exn:fail | |
(struct exn:type exn:fail ()) | |
(define (raise-type-error) | |
(raise (exn:type | |
"type error" | |
(current-continuation-marks)))) | |
(define (interp e) | |
(error 'implementme)) | |
(define (type-check? e) | |
(error 'implementme)) | |
(define example-term | |
(elet "x" (evec (list 1 2 3)) | |
(egetvec (eident "x") 1))) | |
(define example-term-2 | |
(elet "x" (evec (list 1 2 3)) | |
(egetvec (eident "x") 10))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment