uahgi2/expander.rkt
Tan Kian-ting 754c05fa50
Some checks are pending
CI / Build on Racket 'stable' (BC) (push) Waiting to run
CI / Build on Racket 'stable' (CS) (push) Waiting to run
CI / Build on Racket 'current' (BC) (push) Waiting to run
CI / Build on Racket 'current' (CS) (push) Waiting to run
fix namespace catching error
2025-09-29 22:12:15 +08:00

40 lines
1 KiB
Racket

#lang br/quicklang
(namespace-require 'racket/base) ; must be added for the currect namespace
(define paperwidth #f)
(define paperheight #f)
(define (set x y) (set! x y))
(define (add x y) (+ x y))
(provide (matching-identifiers-out #rx"^u-" (all-defined-out)))
(define-macro (u-id ID)
#'(string->symbol ID))
(define-macro (u-atom ITEM...)
#'ITEM...)
(define-macro (u-number NUM...)
#'(number->string NUM...))
(define-macro (u-converting-num NUM...)
#'(string->number NUM...))
(define-macro-cases u-expr
[(u-expr (u-atom ITEM)) #'ITEM]
[(u-expr (u-converting-num (u-number NUM))) #'NUM]
[(u-expr X) #'X])
(define-macro-cases u-sexp
[(u-sexp (u-expr (u-atom (u-id "set"))) X Y) #'(set! X Y)]
;[(u-sexp X Y) #'[X Y]]
[(u-sexp REQ OPT ...)
#'(let ([head REQ]
(namespace (current-namespace)))
(namespace-variable-value head namespace) OPT ...)]
)
(define-macro (u-module-begin (u-program LINE ...))
#'(#%module-begin
LINE ...))
(provide (rename-out [u-module-begin #%module-begin]))