according to a regular expression.
The code is reported below
What I see, is that even with a moderate text file (190k)
it is very slow.
I suppose this is due to the continuos string splitting after each
succesfull parse.
Any suggestion ?
Btw, should be fine to have a "scan" function, that works like
"parse", but in which you specify the " token" syntax instead of the separator one.
Regards
Maurizio.
Code: Select all
(define (scan expr str)
(let ((lst '())
(res '()))
(while (set 'res (regex expr str))
(push (first res) lst -1)
(set 'str (slice str (+ (first(rest res)) (first (rest(rest res)))))))
lst))
(define (go)
(let ((expr {[[:alpha:]]+[[:alnum:]]*|[[:digit:]]+|"(""|[^"])*"|'(''|[^'])*'|[[:graph:]]} ))
(scan expr (read-file "myfile.txt"))))