[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 40/255: parsing empty properties
From: |
Eric Schulte |
Subject: |
[elpa] 40/255: parsing empty properties |
Date: |
Sun, 16 Mar 2014 01:02:15 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 406c9bde5d1dac9cf69479373f90ca6ac9f409a0
Author: Eric Schulte <address@hidden>
Date: Thu May 17 19:39:52 2012 -0400
parsing empty properties
---
sgf-files/w-empty-properties.sgf | 6 ++++++
sgf.el | 26 ++++++++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/sgf-files/w-empty-properties.sgf b/sgf-files/w-empty-properties.sgf
new file mode 100644
index 0000000..064ad4a
--- /dev/null
+++ b/sgf-files/w-empty-properties.sgf
@@ -0,0 +1,6 @@
+(;EV[Empty Properties]
+ S[4]
+ RE[]
+ PB[]
+ PW[]
+ C[This file has some empty properties.])
diff --git a/sgf.el b/sgf.el
index a350f66..2c260a3 100644
--- a/sgf.el
+++ b/sgf.el
@@ -111,7 +111,7 @@
(def-edebug-spec parse-many (regexp string body))
(defvar parse-prop-val-re
- "[[:space:]\n\r]*\\[\\([^\000]*?[^\\]\\)\\]")
+ "[[:space:]\n\r]*\\[\\([^\000]*?[^\\]?\\)\\]")
(defvar parse-prop-re
(format "[[:space:]\n\r]*\\([[:alpha:]]+\\(%s\\)+\\)" parse-prop-val-re))
@@ -205,7 +205,6 @@
(defun process-label (label-args)
(mapcar (lambda (l-arg)
- (message "l-arg:%s" l-arg)
(if (string-match "\\([[:alpha:]]+\\):\\(.*\\)" l-arg)
(list
(cons :label (match-string 2 l-arg))
@@ -251,10 +250,14 @@
(defun board-pos-to-string (board pos)
(let ((size (board-size board)))
- (flet ((emph (n) (and (= size 19) ; TODO: emph for other size boards
- (or (= 3 n)
- (= 4 (- size n))
- (= n (/ (- size 1) 2))))))
+ (flet ((emph (n) (cond
+ ((= size 19)
+ (or (= 3 n)
+ (= 4 (- size n))
+ (= n (/ (- size 1) 2))))
+ ((= size 9)
+ (or (= 2 n)
+ (= 4 n))))))
(let ((val (aref board (pos-to-index pos size))))
(cond
((equal val :w) white-piece)
@@ -330,6 +333,10 @@
(update-display))
(pop-to-buffer buffer)))
+(defun display-sgf-file (path)
+ (interactive "f")
+ (display-sgf (car (read-from-file path))))
+
(defun sgf-ref (sgf index)
(let ((part sgf))
(while (car index)
@@ -629,3 +636,10 @@
(stones-for local-board :w))))
(with-sgf-file "sgf-files/2-capture.sgf"
(right 8) (should (tree-equal (counts) '(6 . 0))))))
+
+(ert-deftest sgf-parse-empty-properties ()
+ (with-sgf-file "sgf-files/w-empty-properties.sgf"
+ (should (remove-if-not (lambda (prop)
+ (let ((val (cdr prop)))
+ (and (sequencep val) (= 0 (length val)))))
+ (car sgf)))))
- [elpa] 33/255: removing dead pieces after moves, (continued)
- [elpa] 33/255: removing dead pieces after moves, Eric Schulte, 2014/03/15
- [elpa] 35/255: compiled and caught some minor issues, Eric Schulte, 2014/03/15
- [elpa] 32/255: consolidating utility functions, Eric Schulte, 2014/03/15
- [elpa] 30/255: saving the board configuration with each sgf step, Eric Schulte, 2014/03/15
- [elpa] 18/255: applying moves to a board, Eric Schulte, 2014/03/15
- [elpa] 37/255: remove debug printf, Eric Schulte, 2014/03/15
- [elpa] 34/255: beginning to stub out tests for dead stone removal, Eric Schulte, 2014/03/15
- [elpa] 38/255: more capture tests, failing multistone captures, Eric Schulte, 2014/03/15
- [elpa] 36/255: passing all tests (at least it did this once), Eric Schulte, 2014/03/15
- [elpa] 26/255: improvements, considering labels and moves, Eric Schulte, 2014/03/15
- [elpa] 40/255: parsing empty properties,
Eric Schulte <=
- [elpa] 42/255: more work with tree parsing, Eric Schulte, 2014/03/15
- [elpa] 46/255: TODO: try using load-read-function and try loading these files w/read, Eric Schulte, 2014/03/15
- [elpa] 45/255: looking at a new method of parsing trees, Eric Schulte, 2014/03/15
- [elpa] 44/255: indentation, Eric Schulte, 2014/03/15
- [elpa] 43/255: paren matching, Eric Schulte, 2014/03/15
- [elpa] 49/255: removed debug stuffs, Eric Schulte, 2014/03/15
- [elpa] 47/255: parsing of sgf files with alternative paths working, Eric Schulte, 2014/03/15
- [elpa] 48/255: all tests are passing, Eric Schulte, 2014/03/15
- [elpa] 52/255: more condensed collecting of games w/alternatives, Eric Schulte, 2014/03/15
- [elpa] 51/255: parsing large complex files, Eric Schulte, 2014/03/15