From 831b1d9e9428d4dd4e1b584a287ba8839ca68d13 Mon Sep 17 00:00:00 2001 From: erana Date: Tue, 17 Jan 2012 23:32:15 +0900 Subject: [PATCH] schemedoc own parser load.scm - 2 --- scsh/schemedoc/NEWS | 3 ++- scsh/schemedoc/load.scm | 27 ++++++++++++--------------- scsh/schemedoc/schemedoc.scm | 28 +++++++++++++++++++++------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/scsh/schemedoc/NEWS b/scsh/schemedoc/NEWS index 05d99eb..76db198 100644 --- a/scsh/schemedoc/NEWS +++ b/scsh/schemedoc/NEWS @@ -1,3 +1,4 @@ version 0.1 * printing a regexp on a filename -* explode (file to list) function for file contents +* file to list function for file contents in chars +* load.scm script diff --git a/scsh/schemedoc/load.scm b/scsh/schemedoc/load.scm index 08df26f..89a1060 100644 --- a/scsh/schemedoc/load.scm +++ b/scsh/schemedoc/load.scm @@ -40,20 +40,17 @@ (exit) ;; NOTE exit ))) +(define SCHEMEDOCITEMS '()) +(let ((directoriesl (schemedoc-get-env-list SCHEMEDOCDIR))) + (do ((l directoriesl (cdr l))) + ((null? l) + 0) + (display (directory-files (car l)) ) + (do ((l2 (directory-files (car l)) (cdr l2))) + ((null? l2)0) + (set! SCHEMEDOCITEMS (append SCHEMEDOCITEMS (list (schemedoc-parser-grep (car l2))))) + ))) -;;(for-each schemedoc-parser-grep SCHEMEDOCDIR) -(define directoriesl (schemedoc-get-env-list SCHEMEDOCDIR)) -(for-each display directoriesl) -(display directoriesl) -(do ((l directoriesl (cdr l))) - ((null? l) - 0) - (display (directory-files (car l)) ) - (do ((l2 (directory-files (car l)) (cdr l2))) - ((null? l2)0) - (schemedoc-parser-grep (car l2))) - ) +(display "Your search is in the variable SCHEMEDOCITEMS list.")(newline) +(display "You can regexp it if you want.")(newline) - - -;;(for-each directory-files directoriesl) diff --git a/scsh/schemedoc/schemedoc.scm b/scsh/schemedoc/schemedoc.scm index fd69b8d..7c3fa83 100644 --- a/scsh/schemedoc/schemedoc.scm +++ b/scsh/schemedoc/schemedoc.scm @@ -85,15 +85,29 @@ (define (schemedoc-parser-grep filename) (let ((le (schemedoc-parser-doc filename)) (line "") - (lines '())) + (headline "") + (itemlines '()) + (itemtext "") + (itemtexts '()) + ) (do ((l le (cdr l))) ((eof-object? l)0) - (if (and (eq? (car l) #\newline)(string<=? "=item" line)) - (begin - (set! lines (append lines (list line))) - (set! line ""))) - (set! line (string-append line (string (car l))))) - (for-each display lines))) + (cond ((and (eq? (car l) #\newline)(string<=? "=item" line)) + (set! itemlines (append itemlines (list line))) + (set! line "") + (set! itemtexts (append itemtexts (list itemtext))) + (set! itemtext "")) + ((and (eq? (car l) #\newline)(string<=? "=head" line)) + (set! headline line) + (set! line "")) + ;;((eq? (car l) #\newline) + + ) + (set! line (string-append line (string (car l)))) + (set! itemtext (string-append itemtext (string (car l)))) + ) + itemtexts + )) (define (schemedoc-get-env-list SCHEMEDOCDIR) (let ((directory "")