stxparam approach
This commit is contained in:
parent
7e605cd081
commit
705ea591b0
|
@ -5,21 +5,18 @@
|
||||||
(all-defined-out))
|
(all-defined-out))
|
||||||
(require (for-syntax racket/syntax racket/list br/datum))
|
(require (for-syntax racket/syntax racket/list br/datum))
|
||||||
|
|
||||||
(define-for-syntax alphasyms (for/list ([i (in-string "ABCDEFGHIJKLMNOPQRSTUVWXYZ")])
|
(require racket/stxparam)
|
||||||
(string->symbol (format "~a" i))))
|
(define-syntax-parameter A
|
||||||
(define-for-syntax stringsyms (map (λ(s) (format-datum "~a$" s)) alphasyms))
|
(λ (stx)
|
||||||
|
(raise-syntax-error (syntax-e stx) "can only be used inside the place")))
|
||||||
|
|
||||||
(define-syntax (basic-module-begin stx)
|
(define #'(basic-module-begin PARSE-TREE ...)
|
||||||
(syntax-case stx ()
|
#'(#%module-begin
|
||||||
[(_ PARSE-TREE ...)
|
(let ([A-inner 0])
|
||||||
(with-syntax ([(VARNAME ...) (datum->syntax stx alphasyms)]
|
(syntax-parameterize
|
||||||
[(STRINGVARNAME ...) (datum->syntax stx stringsyms)])
|
([A (make-rename-transformer #'A-inner)])
|
||||||
#'(#%module-begin
|
(println (quote PARSE-TREE ...))
|
||||||
(define VARNAME 0) ...
|
PARSE-TREE ...))))
|
||||||
(define STRINGVARNAME "") ...
|
|
||||||
(provide VARNAME ... STRINGVARNAME ...)
|
|
||||||
(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)
|
||||||
|
@ -94,8 +91,8 @@
|
||||||
|
|
||||||
(define #'(INPUT PRINT-LIST ";" ID)
|
(define #'(INPUT PRINT-LIST ";" ID)
|
||||||
#'(begin
|
#'(begin
|
||||||
(PRINT (append PRINT-LIST (list ";")))
|
(PRINT (append PRINT-LIST (list ";")))
|
||||||
(set! ID (read-line))))
|
(set! ID (read-line))))
|
||||||
|
|
||||||
(define (GOTO where)
|
(define (GOTO where)
|
||||||
where)
|
where)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user