use suffix! and append!.
							parent
							
								
									49270c2ac6
								
							
						
					
					
						commit
						6fd908da40
					
				| 
						 | 
				
			
			@ -43,7 +43,7 @@ M: c-reader stream-read1
 | 
			
		|||
: read-until-loop ( handle seps accum -- accum ch )
 | 
			
		||||
    pick fgetc dup [
 | 
			
		||||
        pick dupd member-eq?
 | 
			
		||||
        [ [ 2drop ] 2dip ] [ over push read-until-loop ] if
 | 
			
		||||
        [ [ 2drop ] 2dip ] [ suffix! read-until-loop ] if
 | 
			
		||||
    ] [
 | 
			
		||||
        [ 2drop ] 2dip
 | 
			
		||||
    ] if ; inline recursive
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -54,11 +54,11 @@ name>char-hook [
 | 
			
		|||
: (unescape-string) ( accum str i/f -- accum )
 | 
			
		||||
    { sbuf object object } declare
 | 
			
		||||
    [
 | 
			
		||||
        cut-slice [ over push-all ] dip
 | 
			
		||||
        rest-slice next-escape [ over push ] dip
 | 
			
		||||
        cut-slice [ append! ] dip
 | 
			
		||||
        rest-slice next-escape [ suffix! ] dip
 | 
			
		||||
        CHAR: \\ over index (unescape-string)
 | 
			
		||||
    ] [
 | 
			
		||||
        over push-all
 | 
			
		||||
        append!
 | 
			
		||||
    ] if* ;
 | 
			
		||||
 | 
			
		||||
PRIVATE>
 | 
			
		||||
| 
						 | 
				
			
			@ -73,11 +73,11 @@ PRIVATE>
 | 
			
		|||
: (parse-string) ( accum str -- accum m )
 | 
			
		||||
    { sbuf slice } declare
 | 
			
		||||
    dup [ "\"\\" member? ] find [
 | 
			
		||||
        [ cut-slice [ over push-all ] dip rest-slice ] dip
 | 
			
		||||
        [ cut-slice [ append! ] dip rest-slice ] dip
 | 
			
		||||
        CHAR: " = [
 | 
			
		||||
            from>>
 | 
			
		||||
        ] [
 | 
			
		||||
            next-escape [ over push ] dip (parse-string)
 | 
			
		||||
            next-escape [ suffix! ] dip (parse-string)
 | 
			
		||||
        ] if
 | 
			
		||||
    ] [
 | 
			
		||||
        "Unterminated string" throw
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,5 +21,5 @@ M: literate-lexer skip-blank
 | 
			
		|||
 | 
			
		||||
SYNTAX: <LITERATE
 | 
			
		||||
    "LITERATE>" parse-multiline-string string-lines [
 | 
			
		||||
        <literate-lexer> (parse-lines) over push-all
 | 
			
		||||
        <literate-lexer> (parse-lines) append!
 | 
			
		||||
    ] with-nested-compilation-unit ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -173,7 +173,7 @@ PRIVATE>
 | 
			
		|||
    [ appender-for [ each ] dip ] keep like ; inline
 | 
			
		||||
 | 
			
		||||
: >resizable ( seq -- accum ) ! fixes map-concat "cannot apply call to run-time..."
 | 
			
		||||
    [ length ] keep [ new-resizable ] [ over push-all ] bi ;
 | 
			
		||||
    [ length ] keep [ new-resizable ] [ append! ] bi ;
 | 
			
		||||
 | 
			
		||||
: map-concat ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
 | 
			
		||||
    over empty? [ 2drop { } ] [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue