improvements
parent
96c14719cf
commit
948f40e002
@ -0,0 +1,2 @@
|
||||
#lang s-exp br-bf
|
||||
(bf-program (op "+") (op "+") (op "+") (op "+") (op "+") (op "+") (op "+") (op (loop "[" (op ">") (op "+") (op "+") (op "+") (op "+") (op "+") (op "<") (op "-") "]")) (op ">") (op "."))
|
@ -0,0 +1,2 @@
|
||||
#lang br-bf
|
||||
+++++++[>+++++<-]>.
|
@ -1,10 +1,7 @@
|
||||
#lang ragg
|
||||
bf-program : expr*
|
||||
expr : ">"
|
||||
| "<"
|
||||
| "+"
|
||||
| "-"
|
||||
| "."
|
||||
| ","
|
||||
| loop
|
||||
loop : "[" expr* "]"
|
||||
;; use uppercase TOKEN-IDENTIFIERS for classes of tokens
|
||||
;; too numerous to indicate individually
|
||||
;; (e.g., numbers, strings)
|
||||
bf-program : op*
|
||||
op : ">" | "<" | "+" | "-" | "." | "," | loop
|
||||
loop : "[" op* "]"
|
@ -1,14 +1,15 @@
|
||||
#lang racket/base
|
||||
(require parser-tools/lex ragg/support racket/function)
|
||||
(provide tokenize lex)
|
||||
|
||||
(define lex
|
||||
(lexer-src-pos
|
||||
[(char-set "><-.,+[]") lexeme]
|
||||
[whitespace (token '_ lexeme #:skip? #t)]
|
||||
[(eof) (void)]))
|
||||
(require parser-tools/lex ragg/support)
|
||||
(provide tokenize)
|
||||
|
||||
(define (tokenize ip)
|
||||
(port-count-lines! ip)
|
||||
(define next-token-thunk (thunk (lex ip)))
|
||||
next-token-thunk)
|
||||
|
||||
(define lex
|
||||
(lexer
|
||||
[(char-set "><-.,+[]") lexeme]
|
||||
[whitespace (token 'white #:skip? #t)]
|
||||
[(eof) (void)]))
|
||||
|
||||
(define next-token-func (λ _ (lex ip)))
|
||||
next-token-func)
|
||||
|
Loading…
Reference in New Issue