Changeset 34218 in project


Ignore:
Timestamp:
07/01/17 23:32:31 (4 weeks ago)
Author:
kon
Message:

add reader-spec, csv-out stuff

Location:
release/4/csv-xml
Files:
2 added
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/csv-xml/tags/0.11.0/csv-xml.meta

    r27664 r34218  
    88 (doc-from-wiki)
    99 (synopsis "Parsing comma-separated values")
    10  (depends (setup-helper "1.5.2"))
    11  (test-depends testeez)
     10 (depends
     11  (setup-helper "1.5.2")
     12  (check-errors "2.0.2"))
     13 (test-depends testeez test)
    1214 (files
    1315  "csv-xml.meta"
    1416  "csv-xml.scm"
    1517  "csv.ss"
     18  "csv-out.impl"
    1619  "csv-xml.setup"
    1720  "test/run.scm"
  • release/4/csv-xml/tags/0.11.0/csv-xml.scm

    r24274 r34218  
    1 ;;;; csv-xml.scm
     1;;;; csv-xml.scm  -*- Hen -*-
     2;;;; Kon Lovett, Jun '17
     3;;;; Kon Lovett, ??? '??
    24
    35(module csv-xml
    46
    5   (;export
    6     csv->list
    7     csv->sxml
    8     csv-for-each
    9     csv-map
    10     make-csv-reader
    11     make-csv-reader-maker)
     7(;export
     8  ;
     9  reader-spec
     10  ;
     11  make-csv-reader
     12  make-csv-reader-maker
     13  ;
     14  csv->list
     15  csv->sxml
     16  csv-for-each
     17  csv-map
     18  ;
     19  csv-reader? check-csv-reader error-csv-reader
     20  csv-reader-spec? check-csv-reader-spec error-csv-reader-spec
     21  ;
     22  writer-spec
     23  ;
     24  make-csv-writer-maker
     25  make-csv-writer
     26  ;
     27  list->csv
     28  list->sxml
     29  ;
     30  csv-writer? check-csv-writer error-csv-writer
     31  csv-writer-spec? check-csv-writer-spec error-csv-writer-spec)
    1232
    13   (import scheme (except chicken provide))
     33(import scheme)
    1434
    15   ;Need to process `#lang' as well. So just "commented out" the "offending"
    16   ;sections in the source.
    17   #;(define-syntax provide (syntax-rules () ((_ ?x0 ...) (begin))))
    18   (define null '())
     35(import (except chicken provide))
    1936
    20   (include "csv.ss")
     37;;;
     38
     39;Need to process `#lang' as well. So just "commented out" the "offending"
     40;sections in the source.
     41#;(define-syntax provide (syntax-rules () ((_ ?x0 ...) (begin))))
     42(define null '())
     43
     44(include "csv.ss")
     45
     46;;;
     47
     48(import (only data-structures conc intersperse ->string))
     49(require-library data-structures)
     50
     51#;(import (only list-utils alist?))
     52(import (only (srfi 1) every iota append! map))
     53(require-library (srfi 1))
     54
     55(import (only type-checks define-check+error-type check-string check-list))
     56(require-library type-checks)
     57
     58;(from list-utils egg)
     59(define (alist? obj)
     60  (and
     61    (list? obj)
     62    (every pair? obj) ) )
     63
     64;very loose ...
     65(define csv-reader-spec? alist?)
     66(define-check+error-type csv-reader-spec)
     67
     68(define csv-reader? procedure?)
     69(define-check+error-type csv-reader)
     70
     71(define (reader-spec
     72          #!key
     73          (newline-type 'lax)
     74          (separator-chars '(#\,))
     75          (quote-char #\")
     76          (quote-doubling-escapes? #t)
     77          (comment-chars '())
     78          (whitespace-chars '(#\space))
     79          (strip-leading-whitespace? #f)
     80          (strip-trailing-whitespace? #f)
     81          (newlines-in-quotes? #t))
     82  `((newline-type . ,newline-type)
     83    (separator-chars . ,separator-chars)
     84    (quote-char . ,quote-char)
     85    (quote-doubling-escapes? . ,quote-doubling-escapes?)
     86    (comment-chars . ,comment-chars)
     87    (whitespace-chars . ,whitespace-chars)
     88    (strip-leading-whitespace? . ,strip-leading-whitespace?)
     89    (strip-trailing-whitespace? . ,strip-trailing-whitespace?)
     90    (newlines-in-quotes? . ,newlines-in-quotes?)) )
     91
     92;;;
     93
     94(include "csv-out.impl")
    2195
    2296) ;csv-xml
  • release/4/csv-xml/tags/0.11.0/csv-xml.setup

    r27664 r34218  
    55(verify-extension-name "csv-xml")
    66
    7 (setup-shared-extension-module 'csv-xml (extension-version "0.10.2"))
     7(setup-shared+static-extension-module (extension-name) (extension-version "0.11.0")
     8  #:types? #t
     9  #:inline? #t
     10  #:compile-options '(
     11    -optimize-level 3 -debug-level 2
     12    -no-procedure-checks-for-toplevel-bindings -no-procedure-checks-for-usual-bindings))
  • release/4/csv-xml/tags/0.11.0/tests/run.scm

    r24274 r34218  
    11;;;; csv-xml-test.scm  -*- Hen -*-
    22
    3 (use testeez)
    43(use csv-xml)
    54
     
    87#;(define-syntax require (syntax-rules () ((_ ?x0 ...) (begin))))
    98
     9(use testeez)
    1010(include "test-csv.ss")
    1111
     12(newline)
     13
     14(use test)
     15
     16(define +reader-spec-default+ '(
     17  (newline-type . lax)
     18  (separator-chars #\,)
     19  (quote-char . #\")
     20  (quote-doubling-escapes? . #t)
     21  (comment-chars)
     22  (whitespace-chars #\space)
     23  (strip-leading-whitespace? . #f)
     24  (strip-trailing-whitespace? . #f)
     25  (newlines-in-quotes? . #t)
     26))
     27
     28(test +reader-spec-default+ (reader-spec))
     29
     30(define +reader-spec-default-2+ '(
     31  (newline-type . lax)
     32  (separator-chars #\,)
     33  (quote-char . #\")
     34  (quote-doubling-escapes? . #f)
     35  (comment-chars)
     36  (whitespace-chars #\space)
     37  (strip-leading-whitespace? . #f)
     38  (strip-trailing-whitespace? . #f)
     39  (newlines-in-quotes? . #t)
     40))
     41
     42(test +reader-spec-default-2+ (reader-spec #:quote-doubling-escapes? #f))
     43
     44(test-begin "csv-xml out")
     45
     46(define +writer-spec-default+ '(
     47  (newline . #t)
     48  (separator-char . #\,)
     49  (quote-char . #\")
     50))
     51
     52(test +writer-spec-default+ (writer-spec))
     53
     54(define +writer-spec-default-2+ '(
     55  (newline . #f)
     56  (separator-char . #\,)
     57  (quote-char . #\")
     58))
     59
     60(test +writer-spec-default-2+ (writer-spec #:newline #f))
     61
     62(define +list-in-1+ '((1 22 333) (11 2222 333333)))
     63
     64(define +list->sxml-out-1+ '(
     65  |*TOP*|
     66  (scull
     67    (foo 1)
     68    (bar 22)
     69    (baz 333))
     70  (scull
     71    (foo 11)
     72    (bar 2222)
     73    (baz 333333))
     74))
     75
     76(test +list->sxml-out-1+ (list->sxml +list-in-1+ 'scull '(foo bar baz)))
     77
     78(use ports)
     79
     80(test
     81  "\"1\",\"22\",\"333\"\n\"11\",\"2222\",\"333333\"\n"
     82  (with-output-to-string
     83    (lambda ()
     84      (list->csv +list-in-1+))))
     85
     86(test-exit)
  • release/4/csv-xml/trunk/csv-xml.meta

    r27664 r34218  
    88 (doc-from-wiki)
    99 (synopsis "Parsing comma-separated values")
    10  (depends (setup-helper "1.5.2"))
    11  (test-depends testeez)
     10 (depends
     11  (setup-helper "1.5.2")
     12  (check-errors "2.0.2"))
     13 (test-depends testeez test)
    1214 (files
    1315  "csv-xml.meta"
    1416  "csv-xml.scm"
    1517  "csv.ss"
     18  "csv-out.impl"
    1619  "csv-xml.setup"
    1720  "test/run.scm"
  • release/4/csv-xml/trunk/csv-xml.scm

    r24274 r34218  
    1 ;;;; csv-xml.scm
     1;;;; csv-xml.scm  -*- Hen -*-
     2;;;; Kon Lovett, Jun '17
     3;;;; Kon Lovett, ??? '??
    24
    35(module csv-xml
    46
    5   (;export
    6     csv->list
    7     csv->sxml
    8     csv-for-each
    9     csv-map
    10     make-csv-reader
    11     make-csv-reader-maker)
     7(;export
     8  ;
     9  reader-spec
     10  ;
     11  make-csv-reader
     12  make-csv-reader-maker
     13  ;
     14  csv->list
     15  csv->sxml
     16  csv-for-each
     17  csv-map
     18  ;
     19  csv-reader? check-csv-reader error-csv-reader
     20  csv-reader-spec? check-csv-reader-spec error-csv-reader-spec
     21  ;
     22  writer-spec
     23  ;
     24  make-csv-writer-maker
     25  make-csv-writer
     26  ;
     27  list->csv
     28  list->sxml
     29  ;
     30  csv-writer? check-csv-writer error-csv-writer
     31  csv-writer-spec? check-csv-writer-spec error-csv-writer-spec)
    1232
    13   (import scheme (except chicken provide))
     33(import scheme)
    1434
    15   ;Need to process `#lang' as well. So just "commented out" the "offending"
    16   ;sections in the source.
    17   #;(define-syntax provide (syntax-rules () ((_ ?x0 ...) (begin))))
    18   (define null '())
     35(import (except chicken provide))
    1936
    20   (include "csv.ss")
     37;;;
     38
     39;Need to process `#lang' as well. So just "commented out" the "offending"
     40;sections in the source.
     41#;(define-syntax provide (syntax-rules () ((_ ?x0 ...) (begin))))
     42(define null '())
     43
     44(include "csv.ss")
     45
     46;;;
     47
     48(import (only data-structures conc intersperse ->string))
     49(require-library data-structures)
     50
     51#;(import (only list-utils alist?))
     52(import (only (srfi 1) every iota append! map))
     53(require-library (srfi 1))
     54
     55(import (only type-checks define-check+error-type check-string check-list))
     56(require-library type-checks)
     57
     58;(from list-utils egg)
     59(define (alist? obj)
     60  (and
     61    (list? obj)
     62    (every pair? obj) ) )
     63
     64;very loose ...
     65(define csv-reader-spec? alist?)
     66(define-check+error-type csv-reader-spec)
     67
     68(define csv-reader? procedure?)
     69(define-check+error-type csv-reader)
     70
     71(define (reader-spec
     72          #!key
     73          (newline-type 'lax)
     74          (separator-chars '(#\,))
     75          (quote-char #\")
     76          (quote-doubling-escapes? #t)
     77          (comment-chars '())
     78          (whitespace-chars '(#\space))
     79          (strip-leading-whitespace? #f)
     80          (strip-trailing-whitespace? #f)
     81          (newlines-in-quotes? #t))
     82  `((newline-type . ,newline-type)
     83    (separator-chars . ,separator-chars)
     84    (quote-char . ,quote-char)
     85    (quote-doubling-escapes? . ,quote-doubling-escapes?)
     86    (comment-chars . ,comment-chars)
     87    (whitespace-chars . ,whitespace-chars)
     88    (strip-leading-whitespace? . ,strip-leading-whitespace?)
     89    (strip-trailing-whitespace? . ,strip-trailing-whitespace?)
     90    (newlines-in-quotes? . ,newlines-in-quotes?)) )
     91
     92;;;
     93
     94(include "csv-out.impl")
    2195
    2296) ;csv-xml
  • release/4/csv-xml/trunk/csv-xml.setup

    r27664 r34218  
    55(verify-extension-name "csv-xml")
    66
    7 (setup-shared-extension-module 'csv-xml (extension-version "0.10.2"))
     7(setup-shared+static-extension-module (extension-name) (extension-version "0.11.0")
     8  #:types? #t
     9  #:inline? #t
     10  #:compile-options '(
     11    -optimize-level 3 -debug-level 2
     12    -no-procedure-checks-for-toplevel-bindings -no-procedure-checks-for-usual-bindings))
  • release/4/csv-xml/trunk/tests/run.scm

    r24274 r34218  
    11;;;; csv-xml-test.scm  -*- Hen -*-
    22
    3 (use testeez)
    43(use csv-xml)
    54
     
    87#;(define-syntax require (syntax-rules () ((_ ?x0 ...) (begin))))
    98
     9(use testeez)
    1010(include "test-csv.ss")
    1111
     12(newline)
     13
     14(use test)
     15
     16(define +reader-spec-default+ '(
     17  (newline-type . lax)
     18  (separator-chars #\,)
     19  (quote-char . #\")
     20  (quote-doubling-escapes? . #t)
     21  (comment-chars)
     22  (whitespace-chars #\space)
     23  (strip-leading-whitespace? . #f)
     24  (strip-trailing-whitespace? . #f)
     25  (newlines-in-quotes? . #t)
     26))
     27
     28(test +reader-spec-default+ (reader-spec))
     29
     30(define +reader-spec-default-2+ '(
     31  (newline-type . lax)
     32  (separator-chars #\,)
     33  (quote-char . #\")
     34  (quote-doubling-escapes? . #f)
     35  (comment-chars)
     36  (whitespace-chars #\space)
     37  (strip-leading-whitespace? . #f)
     38  (strip-trailing-whitespace? . #f)
     39  (newlines-in-quotes? . #t)
     40))
     41
     42(test +reader-spec-default-2+ (reader-spec #:quote-doubling-escapes? #f))
     43
     44(test-begin "csv-xml out")
     45
     46(define +writer-spec-default+ '(
     47  (newline . #t)
     48  (separator-char . #\,)
     49  (quote-char . #\")
     50))
     51
     52(test +writer-spec-default+ (writer-spec))
     53
     54(define +writer-spec-default-2+ '(
     55  (newline . #f)
     56  (separator-char . #\,)
     57  (quote-char . #\")
     58))
     59
     60(test +writer-spec-default-2+ (writer-spec #:newline #f))
     61
     62(define +list-in-1+ '((1 22 333) (11 2222 333333)))
     63
     64(define +list->sxml-out-1+ '(
     65  |*TOP*|
     66  (scull
     67    (foo 1)
     68    (bar 22)
     69    (baz 333))
     70  (scull
     71    (foo 11)
     72    (bar 2222)
     73    (baz 333333))
     74))
     75
     76(test +list->sxml-out-1+ (list->sxml +list-in-1+ 'scull '(foo bar baz)))
     77
     78(use ports)
     79
     80(test
     81  "\"1\",\"22\",\"333\"\n\"11\",\"2222\",\"333333\"\n"
     82  (with-output-to-string
     83    (lambda ()
     84      (list->csv +list-in-1+))))
     85
     86(test-exit)
Note: See TracChangeset for help on using the changeset viewer.