[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 66/255: parsing weird comments
From: |
Eric Schulte |
Subject: |
[elpa] 66/255: parsing weird comments |
Date: |
Sun, 16 Mar 2014 01:02:20 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit eb1d5264116d3e0fd7c0a169a18d6e26c4d25c74
Author: Eric Schulte <address@hidden>
Date: Tue May 22 11:38:05 2012 -0400
parsing weird comments
---
sgf-tests.el | 19 +++++++++++++++++++
sgf2el.el | 6 +++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/sgf-tests.el b/sgf-tests.el
index d1e3a8c..1fb34dd 100644
--- a/sgf-tests.el
+++ b/sgf-tests.el
@@ -57,6 +57,25 @@
(should (= 6 (length (car (first (second sgf))))))
(should (= 6 (length (car (second (second sgf))))))))
+(ert-deftest sgf-parse-tree-w-weird-comment ()
+ (let* ((str "(;B[kd]N[(c)]LB[ke:a][pf:b]
+ C[Black 25 takes larger territory on top, and gives up
+ larger territory at the right, as compared to variation
+ (a) \\[3-1-2-1-1-1-2-2-3-2-2-1\\].
+
+ White continues with 'a'. White 'b' is an overplay
+ that sets up a ladder that ends the game, unless
+ White has a ladder break to the lower left.]
+ (;W[ke]N[(a)];B[ng];W[ne];B[mf];W[me];B[je];W[kf];B[jf];W[kg];B[jd];W[pf])
+
+ (;W[pf]
+ C[White 26 is a mistake unless White has a ladder break to the lower
left.]
+ N[mistake (b)];B[pe];W[og];B[rg];W[qh];B[ng];W[ne];B[se];W[qg];B[mf];
+ W[me];B[lf])
+ )")
+ (sgf (sgf2el-str-to-el str)))
+ (should (= 3 (length sgf)))))
+
(ert-deftest sgf-parse-file-test ()
(let ((sgf (sgf2el-file-to-el "sgf-files/jp-ming-5.sgf")))
(should (= 247 (length sgf)))))
diff --git a/sgf2el.el b/sgf2el.el
index d1bb832..997b29d 100644
--- a/sgf2el.el
+++ b/sgf2el.el
@@ -29,10 +29,10 @@
(eval-when-compile (require 'cl))
(defvar prop-re
- "\\([[:alpha:]]+\\)\\(\\([[:space:]]*\\[[^\000]*?[^\\]?\\]\\)+\\)")
+ "\\([[:alpha:]]+\\)\\(\\(\\[\\]\\|[[:space:]]*\\[[^\000]*?[^\\]\\]\\)+\\)")
(defvar prop-val-re
- "\\[\\([^\000]*?[^\\]?\\)\\]")
+ "\\(\\[\\]\\|\\[\\([^\000]*?[^\\]\\)\\]\\)")
(defvar sgf2el-special-properties nil
"A-list of properties and functions to specially convert their values.")
@@ -81,7 +81,7 @@
(setq last-node t))
(let* ((key (sgf2el-convert-prop-key (match-string 2)))
(val (sgf2el-convert-prop-vals key
- (sgf2el-all-matches (match-string 3) prop-val-re 1)))
+ (sgf2el-all-matches (match-string 3) prop-val-re 2)))
(rep (format "%S " (cons key (if (= 1 (length val))
(car val) val)))))
(replace-match rep nil 'literal))))
- [elpa] 55/255: new approach to parsing sgf files into elisp, (continued)
- [elpa] 55/255: new approach to parsing sgf files into elisp, Eric Schulte, 2014/03/15
- [elpa] 61/255: passing first 6 tests, Eric Schulte, 2014/03/15
- [elpa] 59/255: passing first two tests, Eric Schulte, 2014/03/15
- [elpa] 62/255: automatically normalize elisp sgf buffers, Eric Schulte, 2014/03/15
- [elpa] 58/255: able to load and play through games w/sgf2el, Eric Schulte, 2014/03/15
- [elpa] 60/255: passing first five tests, Eric Schulte, 2014/03/15
- [elpa] 64/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 67/255: support for converting *very* large files, Eric Schulte, 2014/03/15
- [elpa] 63/255: consistently passing first 7 tests, Eric Schulte, 2014/03/15
- [elpa] 73/255: indentation, Eric Schulte, 2014/03/15
- [elpa] 66/255: parsing weird comments,
Eric Schulte <=
- [elpa] 72/255: tweak header, Eric Schulte, 2014/03/15
- [elpa] 68/255: misc, Eric Schulte, 2014/03/15
- [elpa] 65/255: cleanup and straightening, Eric Schulte, 2014/03/15
- [elpa] 71/255: other new files, Eric Schulte, 2014/03/15
- [elpa] 69/255: better names for dynamic local variables, Eric Schulte, 2014/03/15
- [elpa] 70/255: bringing in some files from my old go-mode, Eric Schulte, 2014/03/15
- [elpa] 74/255: sending sgf commands to gnugo, Eric Schulte, 2014/03/15
- [elpa] 76/255: sgf-play -> sgf-trans, Eric Schulte, 2014/03/15
- [elpa] 75/255: stubbing out board interaction functions, Eric Schulte, 2014/03/15
- [elpa] 78/255: stubbing out generic trans functions, Eric Schulte, 2014/03/15