Changeset 15803 in project


Ignore:
Timestamp:
09/09/09 05:18:51 (10 years ago)
Author:
Ivan Raikov
Message:

csv now uses abnf-consumers

Location:
release/4/csv
Files:
3 edited

Legend:

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

    r15766 r15803  
    4040        (import scheme chicken data-structures srfi-1 srfi-14)
    4141
    42         (require-library abnf)
    43         (import (prefix abnf abnf:) )
     42        (require-library abnf abnf-consumers)
     43        (import (prefix abnf abnf:)
     44                (prefix abnf-consumers abnf:)
     45                )
    4446
    4547
    46 ;; construct strings from consumed chars
    47 (define scollect (abnf:collect-chars list->string))
    48 
    49 ;; shortcut for (abnf:bind scollect (abnf:longest ... ))
    50 (define-syntax consumed->string
    51   (syntax-rules ()
    52     ((_ p)    (abnf:bind scollect (abnf:longest p)))
    53     ))
    54 
    55 ;; collects all consumed objects of type obj?
    56 (define (consumed-objects obj?)
    57   (lambda (cs)
    58     (and (pair? cs)
    59          (let loop ((cs cs) (ax (list)))
    60            (cond ((null? cs)   (list ax ))
    61                  ((obj? (car cs))
    62                   (loop (cdr cs) (cons (car cs) ax)))
    63                  (else (cons ax cs)))))))
    64 
    65 ;; construct lists from consumed objects
    66 (define (lcollect obj?)
    67   (let ((get-consumed (consumed-objects obj?)))
    68     (lambda rest
    69       (let-optionals rest ((kons identity))
    70         (let ((make (if (procedure? kons) kons (lambda (x) `(,kons . ,x)))))
    71           (lambda (x)
    72             (let ((x1 (get-consumed x)))
    73               (and x1 (pair? (car x1)) (cons (make (car x1)) (cdr x1))))))))))
    74 
    75 (define lcollect-strings (lcollect string?))
    76 
    77 ;; shortcut for (abnf:bind (lcollect-strings ...) (abnf:longest ... ))
    78 (define-syntax consumed-strings->list
    79   (syntax-rules ()
    80     ((_ l p)    (abnf:bind (lcollect-strings l)  (abnf:longest p)))
    81     ((_ p)      (abnf:bind (lcollect-strings)    (abnf:longest p)))
    82     ))
    83 
    8448(define (non-escaped delim)
    85   (consumed->string
     49  (abnf:bind-consumed->string
    8650   (abnf:repetition
    8751    (abnf:set
     
    10064  (abnf:concatenation
    10165   (abnf:drop-consumed abnf:dquote)
    102    (consumed->string
     66   (abnf:bind-consumed->string
    10367    (abnf:repetition
    10468     (abnf:alternatives
     
    11781 
    11882(define (record delim)
    119   (consumed-strings->list 'record
     83  (abnf:bind-consumed-strings->list 'record
    12084   (abnf:concatenation
    12185    (field delim)
  • release/4/csv/csv.setup

    r15766 r15803  
    1717
    1818  ;; Assoc list with properties for your extension:
    19   '((version 1.0)
     19  '((version 1.1)
    2020    (documentation "csv.html")
    2121    ))
  • release/4/csv/tests/run.scm

    r15766 r15803  
    99               (record "Test 4" "Test 5" ))
    1010             (pcsv "Test 1|Test 2|Test 3\r\nTest 4|Test 5\r\n")))
    11 
    12              
    13 
    14 
Note: See TracChangeset for help on using the changeset viewer.