support shell args

pull/10/head
Matthew Butterick 8 years ago
parent 29f13113f7
commit e571d9b372

@ -8,7 +8,10 @@
([((b-line NUM STMT ...) ...) #'(LINE ...)] ([((b-line NUM STMT ...) ...) #'(LINE ...)]
[(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))] [(LINE-FUNC ...) (prefix-id "line-" #'(NUM ...))]
[(VAR-ID ...) (find-property 'b-id #'(LINE ...))] [(VAR-ID ...) (find-property 'b-id #'(LINE ...))]
[(REQ-SPEC ...) (find-property 'b-require-spec #'(LINE ...))]) [(REQ-SPEC ...) (find-property 'b-require-spec #'(LINE ...))]
[((SHELL-ID SHELL-VAL) ...)
(for/list ([(arg idx) (in-indexed (current-command-line-arguments))])
(list (format-id caller-stx "arg~a" idx) arg))]) ; explain why (format-datum 'arg~a idx) won't work
#'(#%module-begin #'(#%module-begin
(module configure-runtime br (module configure-runtime br
(require "runtime.rkt") (require "runtime.rkt")
@ -17,12 +20,13 @@
(require REQ-SPEC) ... (require REQ-SPEC) ...
(define VAR-ID 0) ... (define VAR-ID 0) ...
(provide VAR-ID ...) (provide VAR-ID ...)
(set! SHELL-ID SHELL-VAL) ...
LINE ... LINE ...
(define line-table (define line-table
(apply hasheqv (append (list NUM LINE-FUNC) ...))) (apply hasheqv (append (list NUM LINE-FUNC) ...)))
(parameterize ([current-output-port (parameterize ([current-output-port
(or (current-basic-port) (open-output-nowhere))]) (or (current-basic-port) (open-output-nowhere))])
(void (run line-table)))))) (void (run line-table))))))
(begin-for-syntax (begin-for-syntax
(require racket/list) (require racket/list)

@ -0,0 +1,2 @@
#lang basic-demo-3
10 print "got shell arg" : print arg0 : print arg1
Loading…
Cancel
Save