Created
March 22, 2017 07:31
-
-
Save dockimbel/bffe92eb070b24f5573b677589a94591 to your computer and use it in GitHub Desktop.
Experimental generic loader for non-Red input text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [] | |
load-any: function [input [string!]][ | |
out: make block! 100 | |
junk: none | |
until [ | |
result: load/trap/next input 'pos | |
either error? result/3 [ | |
append any [junk junk: make string! 20] result/2/1 | |
input: next result/2 | |
][ | |
if junk [ | |
append out #junk | |
append out junk | |
junk: none | |
] | |
input: result/2 | |
] | |
append out result/1 | |
empty? result/2 | |
] | |
out | |
] | |
;; load-any "aaa 456z 3 abc" | |
;; == [aaa #junk "456" z 3 abc] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment