[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 14/255: processing simple/core properties
From: |
Eric Schulte |
Subject: |
[elpa] 14/255: processing simple/core properties |
Date: |
Sun, 16 Mar 2014 01:02:10 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit d88b8c499a9d28bc579692d84a8f8db35885edb5
Author: Eric Schulte <address@hidden>
Date: Tue May 15 09:58:20 2012 -0400
processing simple/core properties
---
sgf.el | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/sgf.el b/sgf.el
index 1888fed..d6c4ecc 100644
--- a/sgf.el
+++ b/sgf.el
@@ -150,6 +150,42 @@
(let ((func (cdr (assoc (car raw) sgf-property-alist))))
(if func (cons (car raw) (funcall func (cdr raw))) raw))))
+(defun process-date (date-args)
+ (parse-time-string
+ (if (> 1 (length date-args))
+ (mapconcat #'number-to-string date-args " ")
+ (car date-args))))
+(add-to-list 'sgf-property-alist (cons "DT" #'process-date))
+
+(defun process-board-size (size-args)
+ (string-to-number (car size-args)))
+(add-to-list 'sgf-property-alist (cons "S" #'process-board-size))
+
+(defun process-position (position-string)
+ (flet ((char-to-pos (char)
+ (cond
+ ((or (< char ?A) (> char ?z)) (error "sgf: invalid char %s" char))
+ ((< char ?a) (+ 26 (- char ?A)))
+ (t (- char ?a)))))
+ (cons (char-to-pos (aref position-string 0))
+ (char-to-pos (aref position-string 1)))))
+
+(defun process-move (move-args)
+ (process-position (car move-args)))
+(add-to-list 'sgf-property-alist (cons "B" #'process-move))
+(add-to-list 'sgf-property-alist (cons "W" #'process-move))
+
+(defun process-label (label-args)
+ (mapcar (lambda (l-arg)
+ (message "l-arg:%s" l-arg)
+ (if (string-match "\\([[:alpha:]]+\\):\\(.*\\)" l-arg)
+ (cons (match-string 2 l-arg)
+ (process-position (match-string 1 l-arg)))
+ (error "sgf: malformed label %S" l-arg)))
+ label-args))
+(add-to-list 'sgf-property-alist (cons "LB" #'process-label))
+(add-to-list 'sgf-property-alist (cons "LW" #'process-label))
+
;;; Visualization
;; - define a board format array
- [elpa] branch go created (now a5154e6), Eric Schulte, 2014/03/15
- [elpa] 01/255: parsing properties in SGF files, Eric Schulte, 2014/03/15
- [elpa] 02/255: parse nodes, Eric Schulte, 2014/03/15
- [elpa] 04/255: parse-many macro, Eric Schulte, 2014/03/15
- [elpa] 05/255: parse-nodes, Eric Schulte, 2014/03/15
- [elpa] 03/255: parse-prop -> parse-props, Eric Schulte, 2014/03/15
- [elpa] 08/255: parsing simple trees, Eric Schulte, 2014/03/15
- [elpa] 06/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 07/255: some fixes, Eric Schulte, 2014/03/15
- [elpa] 11/255: ignore data directory, Eric Schulte, 2014/03/15
- [elpa] 14/255: processing simple/core properties,
Eric Schulte <=
- [elpa] 13/255: splitting into sections & stubbing out parsing, Eric Schulte, 2014/03/15
- [elpa] 12/255: headers, Eric Schulte, 2014/03/15
- [elpa] 15/255: board display, Eric Schulte, 2014/03/15
- [elpa] 22/255: example sgf file generated using gcoban, Eric Schulte, 2014/03/15
- [elpa] 17/255: not using "I" as an index, Eric Schulte, 2014/03/15
- [elpa] 20/255: alright "i" *is* a valid position identifier, Eric Schulte, 2014/03/15
- [elpa] 16/255: cleaned up board printing, Eric Schulte, 2014/03/15
- [elpa] 09/255: parsing more complex trees, Eric Schulte, 2014/03/15
- [elpa] 19/255: moving games/ -> sgf-files/, Eric Schulte, 2014/03/15
- [elpa] 10/255: helper functions, Eric Schulte, 2014/03/15