diff --git a/beautiful-racket/br/demo/jsonic-2/reader.rkt b/beautiful-racket/br/demo/jsonic-2/reader.rkt index 60f1361..900f208 100644 --- a/beautiful-racket/br/demo/jsonic-2/reader.rkt +++ b/beautiful-racket/br/demo/jsonic-2/reader.rkt @@ -1,6 +1,10 @@ #lang br/quicklang (require "tokenizer.rkt" "parser.rkt") -(define (read-syntax path port) +(define (syntax-no-bindings? stx) + (and (syntax? stx) + (equal? stx (strip-bindings stx)))) +(define/contract (read-syntax path port) + (path? input-port? . -> . syntax?) (define parse-tree (parse path (tokenize port))) (define module-datum `(module jsonic-module br/demo/jsonic/expander ,parse-tree)) diff --git a/beautiful-racket/br/demo/jsonic-2/tokenizer.rkt b/beautiful-racket/br/demo/jsonic-2/tokenizer.rkt index 56e3d00..3fa9960 100644 --- a/beautiful-racket/br/demo/jsonic-2/tokenizer.rkt +++ b/beautiful-racket/br/demo/jsonic-2/tokenizer.rkt @@ -1,7 +1,13 @@ #lang br/quicklang (require brag/support) -(define (tokenize port) - (define (next-token) + +(define (token? x) + (or (eof-object? x) (string? x) (token-struct? x))) + +(define/contract (tokenize port) + (input-port? . -> . (-> token?)) + (define/contract (next-token) + (-> token?) (define our-lexer (lexer [(eof) eof]