[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 42/255: more work with tree parsing
From: |
Eric Schulte |
Subject: |
[elpa] 42/255: more work with tree parsing |
Date: |
Sun, 16 Mar 2014 01:02:15 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit fbaa17b0a19286fabdc13032b23027db8a0044a6
Author: Eric Schulte <address@hidden>
Date: Fri May 18 10:16:44 2012 -0400
more work with tree parsing
---
sgf.el | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/sgf.el b/sgf.el
index 9bb065d..2d00c42 100644
--- a/sgf.el
+++ b/sgf.el
@@ -120,7 +120,7 @@
(format "[[:space:]\n\r]*;\\(\\(%s\\)+\\)" parse-prop-re))
(defvar parse-tree-part-re
- (format "[[:space:]\n\r]*(\\(%s\\)[[:space:]\n\r]*\\([()]\\)" parse-node-re))
+ (format "[[:space:]\n\r]*(\\(%s\\)[[:space:]\n\r]*[()]" parse-node-re))
(defun parse-prop-ident (str)
(let ((end (if (and (<= ?A (aref str 1))
@@ -147,10 +147,25 @@
(collect (parse-props (match-string 1 str)))))
(defun parse-trees (str)
- (parse-many parse-tree-part-re str
- (setq start (match-beginning 2))
- (let ((tree-part (parse-nodes (match-string 1 str))))
- (collect tree-part))))
+ (let ((cont-p 0))
+ (parse-many parse-tree-part-re str
+ (setq
+ start (match-beginning 2)
+ res (add-tree cont-p (save-match-data
+ (parse-nodes (match-string 1 str))) res)
+ cont-p
+ (+ cont-p
+ (if (string= "(" (substring (match-string 0 str)
+ (1- (length (match-string 0 str)))))
+ 1 -1))))))
+
+(defun add-tree (cont-p tree-part res)
+ (flet ((do-car (n acc) (if (<= n 0) acc (do-car (1- n) `(car ,acc)))))
+ (if (null res)
+ (setf res (nreverse tree-part))
+ ;; TODO: almost there but need to push onto the end
+ (eval `(push (nreverse tree-part) ,(do-car (1- cont-p) 'res)))))
+ res)
(defun read-from-buffer (buffer)
(process (parse-trees (with-current-buffer buffer (buffer-string)))))
- [elpa] 35/255: compiled and caught some minor issues, (continued)
- [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, 2014/03/15
- [elpa] 42/255: more work with tree parsing,
Eric Schulte <=
- [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
- [elpa] 39/255: passing all tests, Eric Schulte, 2014/03/15