* simple "text database table" reader
@ 2002-08-26 8:18 Thien-Thi Nguyen
0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2002-08-26 8:18 UTC (permalink / raw)
Cc: spacey-guile-db, guile-user
[-- Attachment #1: Type: text/plain, Size: 707 bytes --]
folks,
appended are two files, a script to read "text database table" files,
and such a file (used by the script for "testing" ;-) -- note that in
the .tdt file, everything before first formfeed is "header" space for
config, stored procedures, comments, ascii art, etc.
works w/ guile-1.4.1.7.DATE and probably others that have (ice-9 rdelim)
and (ice-9 regex). this will be deployed in the near future and folded
into ttn-pers-scheme eventually. i'm posting now so as to not forget
later.
fyi, probably guile-projects will move from .alist to .tdt as an interim
step before the full move to postgres backend -- text is just so easy to
work with...
thi
_______________________________________________
[-- Attachment #2: z --]
[-- Type: application/octet-stream, Size: 2967 bytes --]
#!/bin/sh
exec guile -s $0 # -*- scheme -*-
!#
;;; Copyright (C) 2002 Thien-Thi Nguyen
;;; This program is provided under the terms of the GNU GPL, version 2.
;;; See http://www.fsf.org/copyleft/gpl.html for details.
(debug-enable 'debug 'backtrace)
(use-modules (ice-9 rdelim) (ice-9 regex))
(define (read-zonk-trailing-ws port)
(let ((val (read port)))
(let loop ((c (peek-char port)))
(case c
((#\space #\tab)
(read-char port)
(loop (peek-char port)))
((#\newline)
(read-char port))))
val))
(define (text-db-table-config . stuff)
(let* ((delim (assq-ref stuff 'delim))
(specs (assq-ref stuff 'fields))
(fgroks (map (lambda (spec)
(case (cadr spec)
((sexp) read)
((sexp-line) read-zonk-trailing-ws)
((line) read-line)
((rest-lines)
(lambda (port)
(read-delimited delim port)))
(else
(error "unknown fgrok type:" spec))))
specs))
(read-record (lambda (port)
(catch 'done
(lambda ()
(map (lambda (name fgrok)
(let ((val (fgrok port)))
(if (eof-object? val)
(throw 'done val)
(cons name val))))
(map car specs) fgroks))
(lambda (key done-val)
done-val)))))
(lambda (key)
(case key
((delim) delim)
((names) (map car specs))
((read-record) read-record)))))
(define (read-text-db port)
(seek port 0 SEEK_SET)
(let ((config (let loop ((start (seek port 0 SEEK_CUR))
(line (read-line port)))
(cond ((string-match "^\\(text-db-table-config" line)
(seek port start SEEK_SET)
(eval-in-module (read port) (current-module)))
(else
(loop (seek port 0 SEEK_CUR)
(read-line port)))))))
(read-delimited (config 'delim) port)
(let loop ((record ((config 'read-record) port)) (acc '()))
(if (eof-object? record)
(reverse acc)
(loop ((config 'read-record) port)
(cons record acc))))))
;; test
(for-each (lambda (x)
(for-each (lambda (pair)
(format #t "~A: ~A\n"
(car pair) (cdr pair)))
x)
(write-line '-------------))
(read-text-db (open-input-file "srfi-status.tdt")))
[-- Attachment #3: srfi-status.tdt --]
[-- Type: application/octet-stream, Size: 5075 bytes --]
srfi-status.tdt
$Id$
(text-db-table-config
'(delim . "\f")
'(fields (srfi sexp-line)
(status sexp-line)
(title line)
(comment rest-lines)))
\f
SRFI
Status
Comments
\f
0
((full "1.5.x"))
Feature based conditional expansion construct
Supported by default.
\f
1
((partial "1.4") (full "1.5.x"))
List Library
Guile has @code{(ice-9 common-list)}, which meets a lot of the srfi-1
specification, although not all. [todo:differences]
2001/04/30: Rob Browning is working on incorporating the
reference implementation into Guile. He is currently waiting
to hear back from Olin Shivers re copyright.
2001/06/07: Martin Grabmueller has independently implemented srfi-1.
For guile-1.5.x, you can use @code{(srfi srfi-1)}.
\f
2
((full "1.4"))
AND-LET*: an AND with local bindings, a guarded LET* special form
For guile-1.4, use @code{(ice-9 and-let*)}.
For guile-1.4.1 and guile-1.5.x, use @code{(ice-9 and-let-star)},
although the Scheme identifier is still "and-let*".
For guile-1.5.x, you can also use @code{(srfi srfi-2)}.
\f
3
(n/a)
List Set Library
(withdrawn)
\f
4
((partial "1.4") (full "1.5.x"))
Homogeneous numeric vector datatypes
See @code{(ice-9 arrays)} for uniform vector support. However, note that
the names read/print syntax are different than the srfi-4 spec.
For guile-1.5.x, use @code{(srfi srfi-4)}.
\f
5
(no)
A compatible @code{let} form with signatures and rest arguments
\f
6
((no "1.4") (full "1.5.x"))
Basic String Ports
For guile-1.4, use @code{call-with-input-string},
@code{call-with-output-string},
@code{with-input-from-string}
and @code{with-output-to-string}.
For guile-1.5.x, use @code{(srfi srfi-6)}.
\f
7
(no)
Feature-based program configuration language
\f
8
((no "1.4") (full "1.5.x"))
RECEIVE: Binding to multiple values
For guile-1.5.x, use either @code{(ice-9 receive)}
or @code{(srfi srfi-8)}.
\f
9
((no "1.4") (full "1.5.x"))
Defining Record Types
Guile has @code{make-record-type},
@code{record-constructor}, @code{record-predicate},
@code{record-accessor} and @code{record-modifier}.
For guile-1.5.x, use @code{(srfi srfi-9)}.
\f
10
((no "1.4") (full "1.5.x"))
Sharp-Comma External Form
For guile-1.5.x, use @code{(srfi srfi-10)}.
\f
11
((no "1.4") (full "1.5.x"))
Syntax for receiving multiple values
For guile-1.5.x, use @code{(srfi srfi-11)}.
\f
12
(n/a)
Exception Handling
(withdrawn)
\f
13
((partial "1.4") (partial "1.5.x"))
String Library
Guile has @code{(ice-9 string-fun)}, which meets a lot of the srfi-13
specification, although not all.
For guile-1.5.x, use @code{(srfi srfi-13)}. Note that
currently, these are not implemented:
@example
string-parse-start+end
string-parse-final-start+end
let-string-start+end
check-substring-spec
substring-spec-ok?
make-kmp-restart-vector
kmp-step
string-search-kmp
@end example
\f
14
((no "1.4") (full "1.5.x"))
Character-Set Library
For guile-1.5.x, use @code{(srfi srfi-14)}.
\f
15
((partial "1.4"))
Syntax for dynamic scoping
Guile has @code{make-fluid}, @code{with-fluids}, etc.
These can probably be made to fit the srfi-15 specification.
\f
16
((no "1.4") (full "1.5.x"))
Syntax for procedures of variable arity
For guile-1.5.x, use @code{(srfi srfi-16)}.
\f
17
((partial "1.4") (full "1.5.x"))
Generalized set!
Guile supports generalized @code{set!} by default, but it is not fully
compliant. For guile-1.5.x, use @code{(srfi srfi-17)}.
\f
18
(maybe)
Multithreading support
Guile can be built with cooperative threading, which has Thread,
Mutex, Condition Variable and Time data types. [todo:differences]
\f
19
((partial "1.4") (full "1.5.x"))
Time Data Types and Procedures
Guile has @code{current-time}, @code{get-internal-real-time},
etc., but these are nowhere near the completeness of srfi-19.
For guile-1.5.x, use @code{(srfi srfi-19)}.
\f
20
(n/a)
Simple object system
(withdrawn)
\f
21
(no)
Real-time multithreadding support
\f
22
(no)
Running Scheme Scripts on Unix
\f
23
((full "1.4"))
Error reporting mechanism
Supported by default.
\f
24
(n/a)
Define-syntax in local lexical scopes
(withdrawn)
\f
25
(maybe)
Multi-dimensional Array Primitives
Guile supports multi-dimensional arrays. [todo:differences]
\f
26
(no)
Notation for Specializing Parameters without Currying
\f
27
(maybe)
Sources of Random Bits
Guile has the @code{*random-state*} variable, and procedures
@code{seed->random-state}, @code{copy-random-state}, @code{random},
and others. [todo:differences]
\f
28
(partial)
Basic Format Strings
Guile @code{format} doesn't handle the @code{~%} and
@code{~~}, but does handle the @code{~A} and @code{~S}.
\f
29
(no)
Localization
\f
30
(no)
Nested Multi-Line Comments
\f
31
(n/a)
A special form REC for recursive evaluation
(still in "draft" status)
\f
32
(n/a)
Sort Libraries
(still in "draft" status)
\f
33
(n/a)
Integer Bitwise-operation Library
(still in "draft" status)
\f
34
(n/a)
Exception Handling for Programs
(still in "draft" status)
\f
35
(n/a)
Conditions
(still in "draft" status)
\f
36
(n/a)
I/O Conditions
(still in "draft" status)
\f
SRFI
Status
Comments
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-08-26 8:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-26 8:18 simple "text database table" reader Thien-Thi Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).