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

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

@ -31,9 +31,13 @@
(define-macro (b-func FUNC-ID ARG ...)
#'(if (procedure? FUNC-ID)
(let ([result (FUNC-ID ARG ...)])
(if (boolean? result)
(if result 1 0)
result))
(cond
[(number? result) (b-expr result)]
[(string? result) result]
[(boolean? result) (if result 1 0)]
[else
(raise-line-error
(format "unknown data type: ~v" result))]))
(raise-line-error
(format "expected ~a to be a function, got ~v"
'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-def : /"def" b-id /"(" ID [/"," ID]* /")" /"=" b-expr
b-import : /"import" b-import-name
@b-import-name : (ID | STRING)
@b-import-name : ID | STRING
b-expr : b-or-expr
b-or-expr : [b-or-expr "or"] b-and-expr
b-and-expr : [b-and-expr "and"] b-not-expr

Loading…
Cancel
Save