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

@ -8,15 +8,16 @@
([((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))])
(list (suffix-id #'arg idx #:context caller-stx) val))])
#'(#%module-begin
(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) ...
@ -32,6 +33,6 @@
(remove-duplicates
(for/list ([stx (in-list (stx-flatten line-stxs))]
#:when (syntax-property stx which))
stx)
stx)
#:key syntax->datum)))

@ -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
@ -35,4 +35,4 @@ b-expt : [b-expt ("^")] b-value
@b-value : b-number | b-id | /"(" b-expr /")" | b-func
b-func : ID /"(" b-expr [/"," b-expr]* /")"
@b-number : INTEGER | DECIMAL
b-repl : (b-statement | b-expr) (/":" [b-repl])*
b-repl : (b-statement | b-expr) (/":" [b-repl])*

Loading…
Cancel
Save