Changeset 14756 in project


Ignore:
Timestamp:
05/24/09 03:56:42 (10 years ago)
Author:
Ivan Raikov
Message:

some small code reorganization in abnf

Location:
release/4/abnf
Files:
2 edited

Legend:

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

    r14702 r14756  
    4646          optional-sequence
    4747          set set-from-string
    48           bind drop consume collect
     48          bind drop consume collect 
    4949          )
    5050
     
    202202             (else  (list (reverse lst) rst))))))
    203203
    204 (define ($ cs)
    205   (let loop ((cs cs) (ax (list)))
    206     (cond ((null? cs)         `(,ax))
    207           ((atom? (car cs))   (loop (cdr cs) (cons (car cs) ax)))
    208           (else               (cons ax cs)))))
    209204
    210205(define (collect . rest)
    211   (let-optionals rest ((label #f))
    212     (let ((make (if label (lambda (x) `(,label ,(car x))) car)))
     206  (define (consumed-atoms cs)
     207    (and (pair? cs)
     208         (let loop ((cs cs) (ax (list)))
     209           (cond ((null? cs)         `(,ax))
     210                 ((atom? (car cs))   (loop (cdr cs) (cons (car cs) ax)))
     211                 (else               (cons ax cs))))))
     212  (let-optionals rest ((kons #f))
     213    (let ((make (cond ((symbol? kons) (lambda (x) `(,kons ,(car x))))
     214                      ((procedure? kons) (lambda (x) (kons (car x))))
     215                      (else car))))
    213216      (lambda (x)
    214         (or (and (pair? x) (let ((x1 ($ x)))
    215                              (cons (make x1) (cdr x1)))) x)))))
     217        (let ((x1 (consumed-atoms x)))
     218          (and x1 (cons (make x1) (cdr x1))))))))
    216219
    217220
  • release/4/abnf/abnf.setup

    r14702 r14756  
    1717
    1818  ;; Assoc list with properties for your extension:
    19   '((version 1.3)
     19  '((version 1.4)
    2020    (documentation "abnf.html")
    2121    ))
Note: See TracChangeset for help on using the changeset viewer.