/lib/skipwhite.arc

http://github.com/alimoeeny/arc · Unknown · 25 lines · 24 code · 1 blank · 0 comment · 0 complexity · bb8097cda62b2ac3beaec3bd6227323d MD5 · raw file

  1. ; place in own library to abide by the LGPL
  2. ;
  3. ; skip-whitespace is copied from
  4. ; http://download.plt-scheme.org/doc/352/html/mzscheme/mzscheme-Z-H-11.html#node_sec_11.2.8
  5. ; which has the following licence:
  6. ;
  7. ; Copyright Š1995-2006 Matthew Flatt
  8. ;
  9. ; Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Library General Public License, Version 2 published by the Free Software Foundation.
  10. ;
  11. ; [ ] in source changed to ( ) to avoid conflict with brackets.scm
  12. ($:define (skip-whitespace port)
  13. ;; Skips whitespace characters, sensitive to the current
  14. ;; readtable's definition of whitespace
  15. (let ((ch (peek-char port)))
  16. (unless (eof-object? ch)
  17. ;; Consult current readtable:
  18. (let-values (((like-ch/sym proc dispatch-proc)
  19. (readtable-mapping (current-readtable) ch)))
  20. ;; If like-ch/sym is whitespace, then ch is whitespace
  21. (when (and (char? like-ch/sym)
  22. (char-whitespace? like-ch/sym))
  23. (read-char port)
  24. (skip-whitespace port))))))