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

24 lines
552 B
Racket

#lang br/quicklang
(module+ reader
(provide read-syntax))
(define (tokenize ip)
(for/list ([tok (in-port read-char ip)])
6 years ago
tok))
6 years ago
(define (parse toks)
(for/list ([tok (in-list toks)])
6 years ago
(define int (char->integer tok))
6 years ago
(for/list ([bit (in-range 7)])
(if (bitwise-bit-set? int bit)
'taco
null))))
(define (read-syntax src ip)
(define toks (tokenize ip))
6 years ago
(define parse-tree (parse toks))
(strip-context
6 years ago
(with-syntax ([PT parse-tree])
#'(module tacofied racket
6 years ago
(for-each displayln 'PT)))))