pull/10/head
Matthew Butterick 8 years ago
parent d60ef52e2b
commit 5613323df7

@ -8,7 +8,8 @@
([((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-import-name #'(LINE ...))] [(IMPORT-NAME ...)
(find-property 'b-import-name #'(LINE ...))]
[((SHELL-ID SHELL-VAL) ...) [((SHELL-ID SHELL-VAL) ...)
(for/list ([(val idx) (in-indexed (current-command-line-arguments))]) (for/list ([(val idx) (in-indexed (current-command-line-arguments))])
(list (suffix-id #'arg idx #:context caller-stx) val))]) (list (suffix-id #'arg idx #:context caller-stx) val))])
@ -16,7 +17,7 @@
(module configure-runtime br (module configure-runtime br
(require basic-demo-3/runtime) (require basic-demo-3/runtime)
(configure-this!)) (configure-this!))
(require REQ-SPEC) ... (require IMPORT-NAME) ...
(define VAR-ID 0) ... (define VAR-ID 0) ...
(provide VAR-ID ...) (provide VAR-ID ...)
(set! SHELL-ID SHELL-VAL) ... (set! SHELL-ID SHELL-VAL) ...

@ -31,9 +31,13 @@
(define-macro (b-func FUNC-ID ARG ...) (define-macro (b-func FUNC-ID ARG ...)
#'(if (procedure? FUNC-ID) #'(if (procedure? FUNC-ID)
(let ([result (FUNC-ID ARG ...)]) (let ([result (FUNC-ID ARG ...)])
(if (boolean? result) (cond
(if result 1 0) [(number? result) (b-expr result)]
result)) [(string? result) result]
[(boolean? result) (if result 1 0)]
[else
(raise-line-error
(format "unknown data type: ~v" result))]))
(raise-line-error (raise-line-error
(format "expected ~a to be a function, got ~v" (format "expected ~a to be a function, got ~v"
'FUNC-ID FUNC-ID)))) 'FUNC-ID FUNC-ID))))

@ -22,7 +22,7 @@ b-for : /"for" b-id /"=" b-expr /"to" b-expr [/"step" b-expr]
b-next : /"next" b-id b-next : /"next" b-id
b-def : /"def" b-id /"(" ID [/"," ID]* /")" /"=" b-expr b-def : /"def" b-id /"(" ID [/"," ID]* /")" /"=" b-expr
b-import : /"import" b-import-name b-import : /"import" b-import-name
@b-import-name : (ID | STRING) @b-import-name : ID | STRING
b-expr : b-or-expr b-expr : b-or-expr
b-or-expr : [b-or-expr "or"] b-and-expr b-or-expr : [b-or-expr "or"] b-and-expr
b-and-expr : [b-and-expr "and"] b-not-expr b-and-expr : [b-and-expr "and"] b-not-expr

Loading…
Cancel
Save