extra exports for repl

hide-top-rule-name
Matthew Butterick 7 years ago
parent 8473f59881
commit 7ea93a0bd9

@ -88,7 +88,13 @@
[PARSE-TO-DATUM (syntax-local-introduce (or (syntax-property rules-stx 'parse-to-datum) (error 'no-parse-to-datum-id-prop)))] [PARSE-TO-DATUM (syntax-local-introduce (or (syntax-property rules-stx 'parse-to-datum) (error 'no-parse-to-datum-id-prop)))]
[PARSE-TREE (syntax-local-introduce (or (syntax-property rules-stx 'parse-tree) (error 'no-parse-tree-id-prop)))] [PARSE-TREE (syntax-local-introduce (or (syntax-property rules-stx 'parse-tree) (error 'no-parse-tree-id-prop)))]
[MAKE-RULE-PARSER (syntax-local-introduce (or (syntax-property rules-stx 'make-rule-parser) (error 'no-make-rule-parser-id-prop)))] [MAKE-RULE-PARSER (syntax-local-introduce (or (syntax-property rules-stx 'make-rule-parser) (error 'no-make-rule-parser-id-prop)))]
[ALL-TOKEN-TYPES (syntax-local-introduce (or (syntax-property rules-stx 'all-token-types) (error 'no-all-token-types-id-prop)))]) [ALL-TOKEN-TYPES (syntax-local-introduce (or (syntax-property rules-stx 'all-token-types) (error 'no-all-token-types-id-prop)))]
[TOKEN (syntax-local-introduce (or (syntax-property rules-stx 'token) (error 'no-token-id-prop)))]
[APPLY-LEXER (syntax-local-introduce (or (syntax-property rules-stx 'apply-lexer) (error 'no-apply-lexer-id-prop)))]
[APPLY-TOKENIZER-MAKER (syntax-local-introduce (or (syntax-property rules-stx 'apply-tokenizer-maker) (error 'no-apply-tokenizer-maker-id-prop)))])
;; this stx object represents the top level of a #lang brag module.
;; so any `define`s are automatically available at the repl.
;; and only identifiers explicitly `provide`d are visible on import.
(quasisyntax/loc rules-stx (quasisyntax/loc rules-stx
(begin (begin
(require br-parser-tools/lex (require br-parser-tools/lex
@ -110,6 +116,11 @@
#;[struct-out exn:fail:parsing] #;[struct-out exn:fail:parsing]
) )
;; helpers from brag/support
(define TOKEN token)
(define APPLY-LEXER apply-lexer)
(define APPLY-TOKENIZER-MAKER apply-tokenizer-maker)
(define-tokens enumerated-tokens (token-type ...)) (define-tokens enumerated-tokens (token-type ...))
;; all-token-types lists all the tokens (except for EOF) ;; all-token-types lists all the tokens (except for EOF)

@ -96,11 +96,9 @@
(syntax-case module-stx () (syntax-case module-stx ()
[(_ RULES-STX) [(_ RULES-STX)
(with-syntax ([RULES-STX (for/fold ([stx #'RULES-STX]) (with-syntax ([RULES-STX (for/fold ([stx #'RULES-STX])
([sym (in-list '(parse parse-to-datum parse-tree make-rule-parser all-token-types))]) ([sym (in-list '(parse parse-to-datum parse-tree make-rule-parser all-token-types token apply-lexer apply-tokenizer-maker))])
(syntax-property stx sym (syntax-local-introduce (replace-context module-stx (datum->syntax #f sym)))))]) (syntax-property stx sym (syntax-local-introduce (replace-context module-stx (datum->syntax #f sym)))))])
#'(#%module-begin #'(#%module-begin RULES-STX))]))
(provide (all-defined-out))
RULES-STX))]))
(define-syntax (rules rules-stx) (define-syntax (rules rules-stx)

Loading…
Cancel
Save