1.25 starter file for class

1.25 starter file for class - parse sexp-> FAE(define(parse...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
;; parse : sexp -> FAE (define (parse expr) (cond [(number? expr) (num expr)] [(symbol? expr) (id expr)] [(list? expr) (case (first expr) [(+) (add (parse (second expr)) (parse (third expr)))] [(if0) (if0 (parse (second expr)) (parse (third expr)) (parse (fourth expr)))] [(with) (let ([var (first (second expr))] [named-expr (parse (second (second expr)))] [body (parse (third expr))]) (app (fun var body) named-expr))] [(fun) (fun (second expr) (parse (third expr)))] [else (app (parse (first expr)) (parse (second expr)))])])) (define-type FAE [num (n number?)] [add (lhs FAE?) (rhs FAE?)] [id (name symbol?)] [if0 (test FAE?) (pass FAE?) (fail FAE?)] [fun (param symbol?) (body FAE?)] [app (fun-expr FAE?) (arg-expr FAE?)]) (define-type FAE-Value [numV (n number?)] [closureV (param symbol?) (body FAE?) (ds DefrdSub?)]) (define-type DefrdSub [mtSub] [aSub (name symbol?) (value FAE-Value?) (ds DefrdSub?)]) ;; lookup : symbol DefrdSub -> FAE-Value
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

1.25 starter file for class - parse sexp-> FAE(define(parse...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online