|
|
@ -3,12 +3,16 @@
|
|
|
|
(rename-out [basic-module-begin #%module-begin])
|
|
|
|
(rename-out [basic-module-begin #%module-begin])
|
|
|
|
(rename-out [basic-top #%top])
|
|
|
|
(rename-out [basic-top #%top])
|
|
|
|
(all-defined-out))
|
|
|
|
(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)
|
|
|
|
#'(#%module-begin
|
|
|
|
(syntax-case stx ()
|
|
|
|
(println (quote PARSE-TREE ...))
|
|
|
|
[(_ PARSE-TREE ...)
|
|
|
|
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 ...))]))
|
|
|
|
|
|
|
|
|
|
|
|
; #%app and #%datum have to be present to make #%top work
|
|
|
|
; #%app and #%datum have to be present to make #%top work
|
|
|
|
(define #'(basic-top . id)
|
|
|
|
(define #'(basic-top . id)
|
|
|
@ -44,18 +48,18 @@
|
|
|
|
(define vars (make-hasheq))
|
|
|
|
(define vars (make-hasheq))
|
|
|
|
|
|
|
|
|
|
|
|
(define-cases #'statement
|
|
|
|
(define-cases #'statement
|
|
|
|
[#'(statement ID "=" EXPR) #'(hash-set! vars 'ID EXPR)]
|
|
|
|
[#'(statement ID "=" EXPR) #'(set! ID EXPR)]
|
|
|
|
[#'(statement PROC ARG ...) #'(PROC ARG ...)])
|
|
|
|
[#'(statement PROC ARG ...) #'(PROC ARG ...)])
|
|
|
|
|
|
|
|
|
|
|
|
(define-cases #'value
|
|
|
|
(define-cases #'value
|
|
|
|
[#'(value "(" EXPR ")") #'EXPR]
|
|
|
|
[#'(value "(" EXPR ")") #'EXPR]
|
|
|
|
[#'(value ID "(" ARG ... ")") #'(ID ARG ...)]
|
|
|
|
[#'(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
|
|
|
|
(define-cases expr
|
|
|
|
[(_ lexpr op rexpr) (if (op lexpr rexpr)
|
|
|
|
[(_ lexpr op rexpr) (if (op lexpr rexpr)
|
|
|
|
1
|
|
|
|
1
|
|
|
|
0)]
|
|
|
|
0)]
|
|
|
|
[(_ expr) expr])
|
|
|
|
[(_ expr) expr])
|
|
|
|
(provide < > <= >=)
|
|
|
|
(provide < > <= >=)
|
|
|
|
|
|
|
|
|
|
|
|