(let ( check_and_erase (lambda (x type) (let (xe (x) xt (meta xe)) (if (= type xt) xe (println "\n\nType error, expected" type "but got" xt "\n\n"))) ) add_one_impl (lambda (x) (+ x 1)) stlc [ [ 'WS [ "( | | |(;[ -~]* ))+"] (lambda (x) nil)] [ 'stlc_expr '("-?[0-9]+") (lambda (x) (lambda () (with-meta (read-string x) 'int))) ] [ 'stlc_expr '("plus") (lambda (x) (lambda () (with-meta + '(int int int)))) ] [ 'stlc_expr '("call" WS stlc_expr WS stlc_expr WS stlc_expr) (lambda (_ _ c _ a _ b) (lambda () (let ( ae (check_and_erase a 'int) be (check_and_erase b 'int) ce (check_and_erase c '(int int int)) ) (with-meta [ce ae be] 'int) ))) ] [ 'stlc '(stlc_expr) (lambda (x) (check_and_erase x 'int)) ] ] our_expr "call plus 13 20" ) (println "\n\nExpr evaluates to" (eval (read-string our_expr stlc 'stlc)) "\n") )