refac solution

pull/21/head
Matthew Butterick 6 years ago
parent d116cfcb82
commit e88e9b164e

@ -1,5 +1,5 @@
#lang br/quicklang #lang br/quicklang
(require brag/support racket/sequence) (require brag/support)
(module+ reader (module+ reader
(provide read-syntax)) (provide read-syntax))
@ -11,11 +11,12 @@
[any-char (lex input-port)])) [any-char (lex input-port)]))
(define (tokenize ip) (define (tokenize ip)
(define toklets (define toklets (for/list ([toklet (in-port lex ip)])
(for/list ([toklet (in-port lex ip)]) toklet))
toklet)) (let loop ([toklets toklets][acc null])
(for/list ([tok (in-slice 7 toklets)]) (if (null? toklets)
tok)) (reverse acc)
(loop (drop toklets 7) (cons (take toklets 7) acc)))))
(define (parse src toks) (define (parse src toks)
(for/list ([tok (in-list toks)]) (for/list ([tok (in-list toks)])
@ -30,5 +31,10 @@
(define parse-tree (parse src toks)) (define parse-tree (parse src toks))
(strip-context (strip-context
(with-syntax ([PT parse-tree]) (with-syntax ([PT parse-tree])
#'(module untaco racket #'(module taco-mod tacopocalypse-demo
(display (list->string 'PT)))))) PT))))
(define-macro (mb PT)
#'(#%module-begin
(display (list->string 'PT))))
(provide (rename-out [mb #%module-begin]))
Loading…
Cancel
Save