You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket-demo/tacogram-demo/main.rkt

31 lines
788 B
Racket

#lang br/quicklang
(require "grammar.rkt")
(module+ reader
(provide read-syntax))
(define (tokenize ip)
(for/list ([tok (in-port read-char ip)])
6 years ago
tok))
5 years ago
(define (parse src toks)
6 years ago
(define parse-tree-datum (parse-to-datum toks))
(for/list ([leaf (in-list (cdr parse-tree-datum))])
6 years ago
(integer->char
(for/sum ([val (in-list (cdr leaf))]
[power (in-naturals)]
#:when (equal? val '(taco)))
(expt 2 power)))))
6 years ago
(define (read-syntax src ip)
6 years ago
(define toks (tokenize ip))
5 years ago
(define parse-tree (parse src toks))
(strip-context
6 years ago
(with-syntax ([PT parse-tree])
5 years ago
#'(module tacogram-mod tacogram-demo
PT))))
(define-macro (mb PT)
#'(#%module-begin
(display (list->string 'PT))))
(provide (rename-out [mb #%module-begin]))