-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpander.rkt
40 lines (33 loc) · 980 Bytes
/
expander.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#lang br/quicklang
;; Taken from https://stackoverflow.com/questions/20076868/how-to-know-whether-a-racket-variable-is-defined-or-not
(define-syntax (if-defined stx)
(syntax-case stx ()
[(_ id iftrue iffalse)
(let ([where (identifier-binding #'id)])
(if where
(begin
#'iftrue)
(begin
#'iffalse)))]))
(define-macro (lc-module-begin (lc-program LINE ...))
#'(#%module-begin
LINE ...))
(provide (rename-out [lc-module-begin #%module-begin]))
(define-macro (lc-definition IDENT ABSTRACTION)
#'(begin
(if-defined IDENT
(set! IDENT ABSTRACTION)
(define IDENT ABSTRACTION))))
(provide lc-definition)
(define-macro (lc-abstraction VAR EXPR)
#'(λ (VAR) EXPR))
(provide lc-abstraction)
(define-macro (lc-application FUNC VAL)
#'(FUNC VAL))
(provide lc-application)
(define-macro (lc-num NUM)
#'NUM)
(provide lc-num)
(define-macro (lc-line CONTENT)
#'CONTENT)
(provide lc-line)