[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 09/255: parsing more complex trees
From: |
Eric Schulte |
Subject: |
[elpa] 09/255: parsing more complex trees |
Date: |
Sun, 16 Mar 2014 01:02:09 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit af8c08546d812aa01be30f09f61338cc193424bb
Author: Eric Schulte <address@hidden>
Date: Tue May 15 08:00:44 2012 -0400
parsing more complex trees
---
sgf.el | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/sgf.el b/sgf.el
index 1e0f1f0..48b5954 100644
--- a/sgf.el
+++ b/sgf.el
@@ -98,13 +98,14 @@
(collect (parse-props (match-string 1 str)))))
(defun parse-trees (str)
- (parse-many parse-tree-part-re str
- (setq start (match-beginning 2))
- (let ((cont-p (string= (match-string 2 str) "("))
- (tree-part (parse-nodes (match-string 1 str))))
- (setq res (if cont-p
- (list tree-part res)
- (cons tree-part res))))))
+ (let (cont-p)
+ (parse-many parse-tree-part-re str
+ (setq start (match-beginning 2))
+ (let ((tree-part (parse-nodes (match-string 1 str))))
+ (setq res (if cont-p
+ (list tree-part res)
+ (cons tree-part res)))
+ (setq cont-p (string= (match-string 2 str) "("))))))
;;; Tests
@@ -147,3 +148,15 @@
(should (= 1 (length tree)))
(should (= 1 (length (car tree))))
(should (= 10 (length (caar tree))))))
+
+(ert-deftest sgf-parse-nested-tree ()
+ (let* ((str "(;GM[1]FF[4]
+ SZ[19]
+ GN[GNU Go 3.7.11 load and print]
+ DT[2008-12-14]
+ KM[0.0]HA[0]RU[Japanese]AP[GNU Go:3.7.11]
+ (;AW[ja][oa][pa][db][eb] ;AB[fa][ha][ia][qa][cb]))")
+ (tree (parse-trees str)))
+ (should (= 2 (length tree)))
+ (should (= 9 (length (car (first tree)))))
+ (should (= 2 (length (second tree))))))
- [elpa] 07/255: some fixes, (continued)
- [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, 2014/03/15
- [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 <=
- [elpa] 19/255: moving games/ -> sgf-files/, Eric Schulte, 2014/03/15
- [elpa] 10/255: helper functions, Eric Schulte, 2014/03/15
- [elpa] 24/255: right and left implemented but buggy, Eric Schulte, 2014/03/15
- [elpa] 23/255: more complex but more intuitive and useful `range', Eric Schulte, 2014/03/15
- [elpa] 21/255: display sgf file as a go board in a buffer, Eric Schulte, 2014/03/15
- [elpa] 25/255: right and left are mainly working, Eric Schulte, 2014/03/15
- [elpa] 29/255: q now quits a sgf display buffer, Eric Schulte, 2014/03/15
- [elpa] 28/255: adding a major mode for board navigation keys, Eric Schulte, 2014/03/15
- [elpa] 27/255: implementation notes, Eric Schulte, 2014/03/15
- [elpa] 31/255: a test to protect against unwanted state changes, Eric Schulte, 2014/03/15