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/taco-decompiler-demo/main.rkt

29 lines
679 B
Racket

#lang br/quicklang
(module+ reader
(provide read-syntax))
(define (tokenize ip)
(for/list ([tok (in-port read ip)])
6 years ago
tok))
5 years ago
(define (parse src toks)
6 years ago
(for/list ([tok (in-list toks)])
6 years ago
(integer->char
(for/sum ([val (in-list tok)]
[power (in-naturals)]
#:when (eq? val 'taco))
(expt 2 power)))))
(define (read-syntax src ip)
(define toks (tokenize ip))
5 years ago
(define parse-tree (parse src toks))
(strip-context
(with-syntax ([PT parse-tree])
5 years ago
#'(module untaco taco-decompiler-demo
PT))))
(define-macro (mb PT)
#'(#%module-begin
(display (list->string 'PT))))
(provide (rename-out [mb #%module-begin]))