parser_AE - (define (parse sexp) (cond [(number? sexp) (num...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#lang planet plai/plai ; define-type works like structure ; saying that (define-type AE ;defineing a type AE comes with three variation num add sub [num (n number?)] [add (lhs AE?) ;left hand side (rhs AE?)] [sub (lhs AE?) (rhs AE?)]) ;; parse : sexp -! AE ;; to convert s-expressions into AEs
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (define (parse sexp) (cond [(number? sexp) (num sexp)] [(list? sexp) (case (first sexp) [ (+) (add (parse (second sexp)) (parse (third sexp)))] [ (-) (sub (parse (second sexp)) (parse (third sexp)))])]))...
View Full Document

Ask a homework question - tutors are online