start tapl/ dir

This commit is contained in:
Stephen Chang 2014-11-11 18:21:43 -05:00
parent d29aed64b8
commit 69c97a5512
3 changed files with 21 additions and 0 deletions

1
tapl/stlc-tests.rkt Normal file
View File

@ -0,0 +1 @@
#lang s-exp "stlc.rkt"

17
tapl/stlc.rkt Normal file
View File

@ -0,0 +1,17 @@
#lang racket/base
(require
(for-syntax racket/base syntax/parse))
;; Simply-Typed Lambda Calculus
;; - one arg lambda
;; - var
;; - binary app
;; - binary +
;; - integers
(define-syntax (datum/tc stx)
(syntax-parse stx
[(_ . n:integer) ( (syntax/loc stx (#%datum . n)) #'Int)]
[(_ . x)
#:when (type-error #:src #'x #:msg "Literal ~a has unknown type." #'x)
(syntax/loc stx (#%datum . x))]))

3
tapl/typecheck.rkt Normal file
View File

@ -0,0 +1,3 @@
#lang racket/base
;; general type checking utility functions