reformats

pull/10/head
Matthew Butterick 8 years ago
parent db957f3041
commit ee35d0d287

@ -12,14 +12,18 @@
(find-property 'b-import-name #'(LINE ...))] (find-property 'b-import-name #'(LINE ...))]
[(EXPORT-NAME ...) [(EXPORT-NAME ...)
(find-property 'b-export-name #'(LINE ...))] (find-property 'b-export-name #'(LINE ...))]
[((SHELL-ID SHELL-VAL) ...) (handle-shell caller-stx)]) [((SHELL-ID SHELL-VAL) ...)
(make-shell-ids-and-values caller-stx)]
[(UNIQUE-ID ...)
(unique-ids
(syntax->list #'(VAR-ID ... SHELL-ID ...)))])
#'(#%module-begin #'(#%module-begin
(module configure-runtime br (module configure-runtime br
(require basic-demo-3/setup) (require basic-demo-3/setup)
(do-setup!)) (do-setup!))
(require IMPORT-NAME) ... (require IMPORT-NAME) ...
(provide EXPORT-NAME ...) (provide EXPORT-NAME ...)
(define VAR-ID 0) ... (define UNIQUE-ID 0) ...
(set! SHELL-ID SHELL-VAL) ... (set! SHELL-ID SHELL-VAL) ...
LINE ... LINE ...
(define line-table (define line-table
@ -30,17 +34,21 @@
(begin-for-syntax (begin-for-syntax
(require racket/list) (require racket/list)
(define (unique-ids stxs)
(remove-duplicates stxs #:key syntax->datum))
(define (find-property which line-stxs) (define (find-property which line-stxs)
(remove-duplicates (unique-ids
(for/list ([stx (in-list (stx-flatten line-stxs))] (for/list ([stx (in-list (stx-flatten line-stxs))]
#:when (syntax-property stx which)) #:when (syntax-property stx which))
stx) stx)))
#:key syntax->datum))
(define (handle-shell ctxt) (define (make-shell-ids-and-values ctxt)
(for/list (for/list ([idx (in-naturals)]
([(val idx) [val (current-command-line-arguments)])
(in-indexed (current-command-line-arguments))]) (with-pattern
(list (suffix-id #'arg idx #:context ctxt) ([SHELL-ID (suffix-id #'arg idx #:context ctxt)]
(or (string->number val) val))))) [SHELL-VALUE (or (string->number val) val)])
#'(SHELL-ID SHELL-VALUE)))))

@ -1,6 +1,5 @@
#lang basic-demo-3 #lang basic-demo-3
10 print "arg0 is " ; arg0 10 print "arg0 is " ; arg0
20 print "arg1 + arg1 is " ; arg1 + arg1 20 print "arg1 + arg1 is " ; arg1 + arg1
30 print "arg2 is " ; arg2
40 print "arg3 is " ; arg3 40 print "arg3 is " ; arg3
50 print "arg4 is " ; arg4 50 print "arg4 is " ; arg4
Loading…
Cancel
Save