Anonymous user
Compiler/lexical analyzer: Difference between revisions
m
ol example fixed
m (ol example fixed) |
m (ol example fixed) |
||
Line 6,600:
(let-parses (
(lead (get-byte-if (lambda (x) (or (<= #\a x #\z) (<= #\A x #\Z) (= x #\_)))))
(tail (get-
(cons 'identifier (bytes->string (cons lead tail)))))
(define get-integer
(let-parses (
(main (get-
(cons 'integer (string->integer (bytes->string main)))))
Line 6,620:
(define get-string
(let-parses (
(_ (get-imm
(data (get-
(get-word "\\n" #\newline)
(get-word "\\\\" #\\) ;\"
(get-byte-if (lambda (x) (not (or (eq? x
(_ (get-imm
(cons 'string (bytes->string data))))
Line 6,644:
(define token-parser
(let-parses (
(tokens (get-
(_ (get-greedy* get-whitespace)))
tokens))
(define (translate source)
(let ((stream (try-parse token-parser (str-iter source) #t)))
(for-each print (car stream))
(if (null? (cdr stream))
(print 'End_of_input))))
</lang>
|