br-bf start

dev-elider-3
Matthew Butterick 9 years ago
parent 6f5b70086a
commit 1181bdfed1

@ -0,0 +1,14 @@
#lang br
(module reader syntax/module-reader
#:language 'br-bf
#:read bf-read
#:read-syntax bf-read-syntax
(require "tokenizer.rkt" "parser.rkt")
(define (bf-read in)
(syntax->datum (bf-read-syntax #f in)))
(define (bf-read-syntax src ip)
(list (parse src (tokenize ip)))))

@ -0,0 +1,10 @@
#lang ragg
<expr> : ">"
| "<"
| "+"
| "-"
| "."
| ","
| <loop>
<loop> : "["<expr>*"]"

@ -0,0 +1,10 @@
#lang ragg
<expr> : ">"
| "<"
| "+"
| "-"
| "."
| ","
| <loop>
<loop> : "["<expr>*"]"

@ -0,0 +1,24 @@
#lang racket/base
(require parser-tools/lex ragg/support)
(provide tokenize)
(define (tokenize ip)
(port-count-lines! ip)
(define my-lexer
(lexer-src-pos
[(repetition 1 +inf.0 numeric)
(token 'INTEGER (string->number lexeme))]
[upper-case
(token 'STRING lexeme)]
["b"
(token 'STRING " ")]
[";"
(token ";" lexeme)]
[whitespace
(token 'WHITESPACE lexeme #:skip? #t)]
[(eof)
(void)]))
(define (next-token) (my-lexer ip))
next-token)
Loading…
Cancel
Save