diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-15 00:13:17 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-15 00:13:17 +0300 |
commit | a27881a1c5bd7d8f8f42cd6526adf80815acfe63 (patch) | |
tree | 821fa9529cf0989fbad1a61ecf7873aa754b18aa /scm | |
parent | 1ffd88231386c104474103fe641cad7fa535f3ec (diff) | |
download | ellinika-a27881a1c5bd7d8f8f42cd6526adf80815acfe63.tar.gz ellinika-a27881a1c5bd7d8f8f42cd6526adf80815acfe63.tar.bz2 |
Minor change:
* scm/verbop.scm: Use module syntax.
Diffstat (limited to 'scm')
-rw-r--r-- | scm/verbop.scm | 159 |
1 files changed, 85 insertions, 74 deletions
diff --git a/scm/verbop.scm b/scm/verbop.scm index 5192b87..ee86035 100644 --- a/scm/verbop.scm +++ b/scm/verbop.scm @@ -1,5 +1,7 @@ -#! =GUILE_BINDIR=/guile -s -=AUTOGENERATED= +#! /bin/sh +# aside from this initial boilerplate, this is actually -*- scheme -*- code +main='(module-ref (resolve-module '\''(src verbop)) '\'main')' +exec ${GUILE-guile} -l $0 -c "(apply $main (command-line))" "$@" !# ;;;; This file is part of Ellinika ;;;; Copyright (C) 2011 Sergey Poznyakoff @@ -17,6 +19,11 @@ ;;;; You should have received a copy of the GNU General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;; + +;;; Main procedure +(define-module (src verbop) + :export (verbop)) + (use-modules (srfi srfi-1) (xmltools xmltrans) (ellinika elmorph) @@ -742,78 +749,82 @@ Informational options: (define (cons? p) (and (pair? p) (not (list? p)))) -(for-each - (lambda (x) - (cond - ((cons? x) - (case (car x) - ((cleanup) - (set! cleanup-option #t)) - ((database) - (add-conn-param #:db (cdr x))) - ((host) - (add-conn-param #:host (cdr x))) - ((port) - (add-conn-param #:port (string->number (cdr x)))) - ((password) - (add-conn-param #:pass (cdr x))) - ((user) - (add-conn-param #:user (cdr x))) - ((interface) - (add-conn-param #:iface (cdr x))) - ((verbose) - (set! verbose-option #t)) - ((preserve) - (set! preserve-option #t)) - ((debug) - (set! debug-level (string->number (cdr x))) - (set! ellinika:sql-verbose #t)) - ((dry-run) - (set! ellinika:sql-dry-run #t) - (set! ellinika:sql-verbose #t)) - ((help) - (usage) - (exit 0)))) - (else - (set! input-files (cdr x))))) - (getopt-long (command-line) grammar)) - -(if (null? input-files) - (begin - (display "Input files not specified\n" (current-error-port)) - (exit 1))) - -(if (not (ellinika:sql-connect ellinika-sql-connection)) - (begin - (display "Cannot connect to the database\n" (current-error-port)) - (exit 1))) -(set! flect-ident (query-number "SELECT MAX(ident) FROM verbflect")) - -(cond - (cleanup-option - (ellinika:sql-query "DELETE FROM verbflect where ident > 99") - (ellinika:sql-query "DELETE FROM verbclass") - (ellinika:sql-query "DELETE FROM verbtense") - (ellinika:sql-query "DELETE FROM irregular_root") - (ellinika:sql-query "DELETE FROM individual_verb"))) - -(set! class-list - (cons "I" - (if ellinika:sql-dry-run - (list "A" "B1" "B2") - (map - car - (ellinika:sql-query - "SELECT DISTINCT conj FROM conjugation ORDER BY 1"))))) - - -(for-each - (lambda (x) - (if (not (xmltrans:parse-file x)) - (exit 1))) - input-files) - -(ellinika:sql-disconnect) +(define (main . args) + (for-each + (lambda (x) + (cond + ((cons? x) + (case (car x) + ((cleanup) + (set! cleanup-option #t)) + ((database) + (add-conn-param #:db (cdr x))) + ((host) + (add-conn-param #:host (cdr x))) + ((port) + (add-conn-param #:port (string->number (cdr x)))) + ((password) + (add-conn-param #:pass (cdr x))) + ((user) + (add-conn-param #:user (cdr x))) + ((interface) + (add-conn-param #:iface (cdr x))) + ((verbose) + (set! verbose-option #t)) + ((preserve) + (set! preserve-option #t)) + ((debug) + (set! debug-level (string->number (cdr x))) + (set! ellinika:sql-verbose #t)) + ((dry-run) + (set! ellinika:sql-dry-run #t) + (set! ellinika:sql-verbose #t)) + ((help) + (usage) + (exit 0)))) + (else + (set! input-files (cdr x))))) + (getopt-long args grammar)) + + (if (null? input-files) + (begin + (display "Input files not specified\n" (current-error-port)) + (exit 1))) + + (if (not (ellinika:sql-connect ellinika-sql-connection)) + (begin + (display "Cannot connect to the database\n" (current-error-port)) + (exit 1))) + (set! flect-ident (query-number "SELECT MAX(ident) FROM verbflect")) + + (cond + (cleanup-option + (ellinika:sql-query "DELETE FROM verbflect where ident > 99") + (ellinika:sql-query "DELETE FROM verbclass") + (ellinika:sql-query "DELETE FROM verbtense") + (ellinika:sql-query "DELETE FROM irregular_root") + (ellinika:sql-query "DELETE FROM individual_verb"))) + + (set! class-list + (cons "I" + (if ellinika:sql-dry-run + (list "A" "B1" "B2") + (map + car + (ellinika:sql-query + "SELECT DISTINCT conj FROM conjugation ORDER BY 1"))))) + + + (for-each + (lambda (x) + (if (not (xmltrans:parse-file x)) + (exit 1))) + input-files) + + (ellinika:sql-disconnect)) + +;;;; EOF + |