Card alias parsing.
This commit is contained in:
parent
2d0ff00ffb
commit
4d43ce29d8
4 changed files with 28 additions and 4 deletions
2
Makefile
2
Makefile
|
@ -190,7 +190,7 @@ cards.import.scm: $(CARDS-SOURCES)
|
|||
|
||||
MEMBER-PARSER-SOURCES=member-parser.scm member-record.import.scm \
|
||||
testing.import.scm dictionary.import.scm month.import.scm \
|
||||
period.import.scm
|
||||
period.import.scm utils.import.scm
|
||||
|
||||
member-parser.so: member-parser.o
|
||||
member-parser.o: member-parser.import.scm
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
testing
|
||||
dictionary
|
||||
month
|
||||
period)
|
||||
period
|
||||
utils)
|
||||
|
||||
;; Pass 2: known keys and multikeys
|
||||
(define member-schema-known-keys '(nick mail phone name born joined destroyed))
|
||||
|
@ -88,6 +89,15 @@
|
|||
(member-record-add-highlight mr1 line-number msg 3 'error))))
|
||||
((joined)
|
||||
(member-record-sub-set mr output key (string->month (car value))))
|
||||
((card desfire)
|
||||
(member-record-sub-set mr output key
|
||||
(map
|
||||
(lambda (rec)
|
||||
(string-first+rest (car rec)))
|
||||
value)))
|
||||
((credit)
|
||||
;; TODO
|
||||
mr)
|
||||
(else
|
||||
(member-record-sub-set mr output key (car value))))))))
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@
|
|||
((joined)
|
||||
(list k (month->string v)))
|
||||
((card desfire credit)
|
||||
(list k "xxx"
|
||||
#;(table->string
|
||||
(list k
|
||||
(table->string
|
||||
(map
|
||||
(lambda (c)
|
||||
(list (car c) (cdr c)))
|
||||
|
|
14
utils.scm
14
utils.scm
|
@ -30,12 +30,14 @@
|
|||
(
|
||||
filter
|
||||
string-repeat
|
||||
string-first+rest
|
||||
utils-tests!
|
||||
)
|
||||
|
||||
(import scheme
|
||||
(chicken base)
|
||||
(chicken string)
|
||||
(chicken irregex)
|
||||
testing)
|
||||
|
||||
;; Returns a list with elements matching pred? predicate.
|
||||
|
@ -59,6 +61,18 @@
|
|||
(cons str res))
|
||||
(string-intersperse res ""))))
|
||||
|
||||
;; Extracts first token and the rest as separate string
|
||||
(define (string-first+rest str)
|
||||
(let ((dm (irregex-search (irregex "[ \\t]" 'u) str)))
|
||||
(if dm
|
||||
(let* ((sep-idx (irregex-match-start-index dm))
|
||||
(key-str (substring str 0 sep-idx))
|
||||
(sep+val (substring str sep-idx))
|
||||
(val (irregex-replace (irregex "^[ \\t]*" 'u) sep+val "")))
|
||||
(cons key-str val))
|
||||
(cons str ""))))
|
||||
|
||||
|
||||
;; Performs utils module self-tests.
|
||||
(define (utils-tests!)
|
||||
(run-tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue