Changeset 14815 in project


Ignore:
Timestamp:
05/28/09 04:43:50 (10 years ago)
Author:
Ivan Raikov
Message:

this stuff should really be properly implemented

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/abnf/abnf.scm

    r14814 r14815  
    4747          optional-sequence
    4848          set set-from-string
    49           bind consume drop-chars collect-chars
     49          bind drop collect-chars
    5050          )
    5151
     
    142142;; optionally followed by a 'crlf' and (at least) one more wsp.
    143143
    144 (define lwsp (lex:seq (list (lex:pos wsp) (lex:opt crlf) (lex:pos wsp))))
     144(define lwsp (lex:seq (list (lex:pos wsp) (lex:opt (lex:seq (list crlf (lex:pos wsp)))))))
     145
    145146
    146147;; Match /any/ character.
     
    191192             (else #f)))))
    192193
    193 (define (drop-chars p)
    194   (bind (lambda (x) (drop-while char? x)) p))
    195 
    196 (define (consume p)
    197   (lambda (s)
    198     (let loop ((lst (list)) (rst s))
    199       (match (p rst)
    200              ((a rst)  (loop (cons a lst) rst))
    201              (else  (list (reverse lst) rst))))))
    202 
     194
     195(define-record-type box (make-box contents)
     196  box? (contents box-contents ))
     197
     198(define box make-box)
     199(define unbox box-contents)
     200
     201(define (drop p)
     202  (lambda (ss)
     203    (let ((ss1 (map (lambda (s)
     204                      (match s ((eaten food)  (list (list (make-box eaten)) food))
     205                             (else s)))
     206                    ss)))
     207      (match (lex:longest (p ss1))
     208             ((eaten food) (let ((eaten1 (unbox (last eaten))))
     209                             (list (list eaten1 food))))
     210             (else #f)))))
    203211
    204212(define (collect-chars . rest)
Note: See TracChangeset for help on using the changeset viewer.