diff --git a/brag/codegen/codegen.rkt b/brag/codegen/codegen.rkt index e2381f8..9c52134 100755 --- a/brag/codegen/codegen.rkt +++ b/brag/codegen/codegen.rkt @@ -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-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)))] - [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 (begin (require br-parser-tools/lex @@ -110,6 +116,11 @@ #;[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 ...)) ;; all-token-types lists all the tokens (except for EOF) diff --git a/brag/codegen/sexp-based-lang.rkt b/brag/codegen/sexp-based-lang.rkt index 4446ce0..ce2e655 100755 --- a/brag/codegen/sexp-based-lang.rkt +++ b/brag/codegen/sexp-based-lang.rkt @@ -96,11 +96,9 @@ (syntax-case module-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)))))]) - #'(#%module-begin - (provide (all-defined-out)) - RULES-STX))])) + #'(#%module-begin RULES-STX))])) (define-syntax (rules rules-stx)