dev-elider-3
Matthew Butterick 9 years ago
parent fc92d0abfc
commit 2c136222b5

@ -3,12 +3,16 @@
(rename-out [basic-module-begin #%module-begin])
(rename-out [basic-top #%top])
(all-defined-out))
(require (for-syntax racket/syntax))
(require (for-syntax racket/syntax racket/list))
(define #'(basic-module-begin PARSE-TREE ...)
(define-syntax (basic-module-begin stx)
(syntax-case stx ()
[(_ PARSE-TREE ...)
(with-syntax ([(VARNAME ...) (map (λ(c) (format-id stx "~a" (integer->char c))) (range 65 91))])
#'(#%module-begin
(define VARNAME 0) ...
(println (quote PARSE-TREE ...))
PARSE-TREE ...))
PARSE-TREE ...))]))
; #%app and #%datum have to be present to make #%top work
(define #'(basic-top . id)
@ -44,13 +48,13 @@
(define vars (make-hasheq))
(define-cases #'statement
[#'(statement ID "=" EXPR) #'(hash-set! vars 'ID EXPR)]
[#'(statement ID "=" EXPR) #'(set! ID EXPR)]
[#'(statement PROC ARG ...) #'(PROC ARG ...)])
(define-cases #'value
[#'(value "(" EXPR ")") #'EXPR]
[#'(value ID "(" ARG ... ")") #'(ID ARG ...)]
[#'(value ID-OR-DATUM) #'(hash-ref vars 'ID-OR-DATUM (λ _ ID-OR-DATUM))])
[#'(value ID-OR-DATUM) #'ID-OR-DATUM])
(define-cases expr
[(_ lexpr op rexpr) (if (op lexpr rexpr)

Loading…
Cancel
Save