1.28 starter file for class - The first three lines of this...

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

;; The first three lines of this file were inserted by DrScheme. ;; They record information about the language level. #reader(lib "plai-restricted-reader.ss" "plai")((modname rcae-starter) (read- case-sensitive #t) (teachpacks ())) ;; NOTE: this file uses language level "Restricted PLAI Scheme" (not "Pretty Big") ;; parse : sexp -> RCAE (define (parse expr) (cond [(number? expr) (num expr)] [(symbol? expr) (id expr)] [(list? expr) (case (first expr) [(+) (add (parse (second expr)) (parse (third expr)))] [(*) (mul (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))] [(rec) (let ([var (first (second expr))] [named-expr (parse (second (second expr)))] [body (parse (third expr))]) (rec var named-expr body))] [(fun) (fun (second expr) (parse (third expr)))] [else (app (parse (first expr)) (parse (second expr)))])])) (define-type RCAE [num (n number?)] [add (lhs RCAE?) (rhs RCAE?)] [mul (lhs RCAE?) (rhs RCAE?)] [id (name symbol?)] [if0 (test RCAE?) (pass RCAE?) (fail RCAE?)] [fun (param symbol?) (body RCAE?)] [app (fun-expr RCAE?) (arg-expr RCAE?)]
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Winter '08
  • Fisler
  • Semantics, Interp, Env env, type-case Env env

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern