Changeset 37864 in project


Ignore:
Timestamp:
09/01/19 05:48:02 (3 weeks ago)
Author:
Kon Lovett
Message:

stuck w/ #{} support until unbundle (sanity feature defeats)

Location:
release/5/string-utils/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • release/5/string-utils/trunk/string-interpolation-body.scm

    r37863 r37864  
    88;; - Uses ##sys#print-to-string
    99
    10 (: string-interpolate (string #!rest --> list))
     10(: string-interpolate/sanity (string #!rest --> list))
    1111;
    12 (define (string-interpolate str #!key (eval-tag #\#) #;(insane #f))
     12(define (string-interpolate/sanity str #!key (eval-tag #\#) (insane #f))
    1313  (let ((strp (open-input-string str)))
    1414    ;objs - LIFO queue (list) of objects
     
    5353                ;
    5454                ;WART read wrapped expression
    55                 #;((and insane (char=? #\{ ch))
     55                ((and insane (char=? #\{ ch))
    5656                  ;!!! we do not test for #\} !!!
    5757                  (advance (push-object (car (read strp))) #f) )
     
    6565            (advance objs (push-char ch)) ) ) ) ) ) )
    6666
    67 #|
    68 (: string-interpolate/insanity (string #!rest --> list))
     67(: string-interpolate (string #!rest --> list))
    6968;
    70 (define (string-interpolate/insanity str #!key (eval-tag #\#))
    71   (string-interpolate str #:eval-tag eval-tag $:insane #t) )
    72 |#
     69(define (string-interpolate str #!key (eval-tag #\#))
     70  (parameterize ((parentheses-synonyms #t))
     71    (string-interpolate/sanity str #:eval-tag eval-tag #:insane #t) ) )
  • release/5/string-utils/trunk/string-interpolation.scm

    r37863 r37864  
    33;;;; Kon Lovett, Sep '17
    44
    5 (module string-interpolation () #;(string-interpolate)
     5(module string-interpolation (string-interpolate)
    66
    77;reverse-list->string
     
    99(import scheme
    1010  (chicken base)
    11   string-interpolator
    12   string-interpolation-syntax)
     11  (chicken platform)
     12  string-interpolation-syntax
     13  string-interpolator)
    1314
    1415;;;
    1516
    16 (set-sharp-string-interpolation-syntax string-interpolate)
    17 
    18 #;
    1917(set-sharp-string-interpolation-syntax
    20   (if (feature? 'insanity)
    21     string-interpolate/insanity
    22     string-interpolate))
     18  (if (or (feature? 'insanity) (not (feature? 'sanity)))
     19    string-interpolate
     20    string-interpolate/sanity))
    2321
    2422) ;string-interpolation
  • release/5/string-utils/trunk/string-interpolator.scm

    r37863 r37864  
    88
    99(;export
    10   string-interpolate)
     10  string-interpolate
     11  string-interpolate/sanity)
    1112
    1213;reverse-list->string
  • release/5/string-utils/trunk/tests/string-utils-test.scm

    r37863 r37864  
    7070;;
    7171
    72 (import string-interpolation-trans)
     72#|
     73(import (prefix utf8-string-interpolator utf8:))
    7374
    74 (test-group "String Interpolation"
     75(test-group "String Interpolator (UTF-8)"
     76  (let ((res '(##sys#print-to-string (list "听诎䞊海的 " (+ 1 2) " 䞜西埈莵"))))
     77    (test res (utf8:string-interpolate "听诎䞊海的 #(+ 1 2) 䞜西埈莵"))
     78    (test res (utf8:string-interpolate "听诎䞊海的 #(+ 1 2) 䞜西埈莵"))
     79    (test res (utf8:string-interpolate "听诎䞊海的 ${(+ 1 2)} 䞜西埈莵" eval-tag: #\$))
     80    (test res (utf8:string-interpolate "听诎䞊海的 $(+ 1 2) 䞜西埈莵" eval-tag: #\$)) )
     81)
     82|#
     83
     84(import string-interpolator)
     85
     86(test-group "String Interpolator"
    7587  (let ((res '(##sys#print-to-string (list "foo " (+ 1 2) " bar"))))
    7688    (test res (string-interpolate "foo #(+ 1 2) bar"))
     
    8092)
    8193
    82 (import (prefix utf8-string-interpolation-trans utf8::))
    83 
    84 (test-group "String Interpolation (UTF-8)"
    85   (let ((res '(##sys#print-to-string (list "听诎䞊海的 " (+ 1 2) " 䞜西埈莵"))))
    86     (test res (utf8::string-interpolate "听诎䞊海的 #(+ 1 2) 䞜西埈莵"))
    87     (test res (utf8::string-interpolate "听诎䞊海的 #(+ 1 2) 䞜西埈莵"))
    88     (test res (utf8::string-interpolate "听诎䞊海的 ${(+ 1 2)} 䞜西埈莵" eval-tag: #\$))
    89     (test res (utf8::string-interpolate "听诎䞊海的 $(+ 1 2) 䞜西埈莵" eval-tag: #\$)) )
    90 )
    91 
    9294(import string-interpolation-syntax (chicken port))
    9395
    9496;must be "top level"; cannot be test-group
    95 (test-begin "String Interpolation SYNTAX")
     97(test-begin "String Interpolation Syntax")
    9698  ;
    9799  (set-sharp-string-interpolation-syntax string-interpolate)
     
    112114    (list (call-with-input-string "#\"foo ${(+ 1 2)} bar\"" read)))
    113115  (set-sharp-string-interpolation-syntax #f)
    114 (test-end "String Interpolation SYNTAX")
     116  ;
     117(test-end "String Interpolation Syntax")
    115118
    116119;;
  • release/5/string-utils/trunk/utf8-string-interpolation.scm

    r37863 r37864  
    33;;;; Kon Lovett, Sep '17
    44
    5 (module utf8-string-interpolation () #;(string-interpolate)
     5(module utf8-string-interpolation (string-interpolate)
    66
    77(import scheme
    88  (chicken base)
    9   utf8-string-interpolator
    10   string-interpolation-syntax)
     9  (chicken platform)
     10  string-interpolation-syntax
     11  utf8-string-interpolator)
    1112
    1213;;;
    1314
    14 (set-sharp-string-interpolation-syntax string-interpolate)
    15 
    16 #;
    1715(set-sharp-string-interpolation-syntax
    18   (if (feature? 'insanity)
    19     string-interpolate/insanity
    20     string-interpolate))
     16  (if (or (feature? 'insanity) (not (feature? 'sanity)))
     17    string-interpolate
     18    string-interpolate/sanity))
    2119
    2220) ;utf8-string-interpolation
  • release/5/string-utils/trunk/utf8-string-interpolator.scm

    r37863 r37864  
    88
    99(;export
    10   string-interpolate)
     10  string-interpolate
     11  string-interpolate/sanity)
    1112
    1213(import (except scheme read-char #;peek-char #;read)
Note: See TracChangeset for help on using the changeset viewer.