You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket-demo/basic-demo-3/expander.rkt

38 lines
1.4 KiB
Racket

8 years ago
#lang br/quicklang
(require "struct.rkt" "run.rkt" "elements.rkt" "runtime.rkt")
8 years ago
(provide (rename-out [b-module-begin #%module-begin])
(all-from-out "elements.rkt"))
(define-macro (b-module-begin (b-program LINE ...))
(with-pattern
([((b-line NUM STMT ...) ...) #'(LINE ...)]
[(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))]
[(VAR-ID ...) (find-property 'b-id #'(LINE ...))]
8 years ago
[(REQ-SPEC ...) (find-property 'b-import-name #'(LINE ...))]
[((SHELL-ID SHELL-VAL) ...)
8 years ago
(for/list ([(val idx) (in-indexed (current-command-line-arguments))])
(list (suffix-id #'arg idx #:context caller-stx) val))])
8 years ago
#'(#%module-begin
(module configure-runtime br
8 years ago
(require basic-demo-3/runtime)
(configure-this!))
(require REQ-SPEC) ...
8 years ago
(define VAR-ID 0) ...
(provide VAR-ID ...)
(set! SHELL-ID SHELL-VAL) ...
8 years ago
LINE ...
(define line-table
(apply hasheqv (append (list NUM LINE-FUNC) ...)))
(parameterize ([current-output-port (basic-output-port)])
(void (run line-table))))))
8 years ago
(begin-for-syntax
(require racket/list)
(define (find-property which line-stxs)
8 years ago
(remove-duplicates
8 years ago
(for/list ([stx (in-list (stx-flatten line-stxs))]
#:when (syntax-property stx which))
stx)
8 years ago
#:key syntax->datum)))