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.
26 lines
637 B
Racket
26 lines
637 B
Racket
8 years ago
|
#lang br
|
||
|
(require brag/support "gifparser.rkt")
|
||
|
|
||
|
(define the-lexer
|
||
|
(lexer-srcloc
|
||
|
[(eof) (return-without-srcloc eof)]
|
||
|
["GIF" (token 'GIF-HEADER lexeme)]
|
||
|
[any-char (token 'BYTE (char->integer (car (string->list lexeme))))]
|
||
|
))
|
||
|
|
||
|
(define (make-tokenizer ip [path #f])
|
||
|
(port-count-lines! ip)
|
||
|
(lexer-file-path path)
|
||
|
(λ () (the-lexer ip)))
|
||
|
|
||
|
(define (munge ip)
|
||
|
(parse-to-datum (make-tokenizer (reencode-input-port ip "latin1"))))
|
||
|
|
||
|
|
||
|
(module+ test
|
||
|
(require pitfall/binprint)
|
||
|
#;(binprint (open-input-file "test.gif") #:width 24)
|
||
|
|
||
|
#;(munge (open-input-bytes #"GIF87a1234567"))
|
||
|
(munge (open-input-file "test.gif"))
|
||
|
)
|