File: parse.scm

package info (click to toggle)
elk 3.99.8-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,204 kB
  • sloc: ansic: 22,346; lisp: 6,208; makefile: 775; sh: 171; awk: 154; cpp: 92
file content (16 lines) | stat: -rw-r--r-- 448 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
;;; -*-Scheme-*-
;;;
;;; string-tokenize -- parse a string into a list of tokens

(define (string-tokenize s)
  (let ((i 0) (j)
	(n (string-length s)))
    (let loop ((args '()))
      (while (and (< i n) (char-whitespace? (string-ref s i)))
	(set! i (1+ i)))
      (if (>= i n)
	(reverse! args)
        (set! j i)
	(while (and (< i n) (not (char-whitespace? (string-ref s i))))
	  (set! i (1+ i)))
        (loop (cons (substring s j i) args))))))