[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 51/255: parsing large complex files
From: |
Eric Schulte |
Subject: |
[elpa] 51/255: parsing large complex files |
Date: |
Sun, 16 Mar 2014 01:02:18 +0000 |
eschulte pushed a commit to branch go
in repository elpa.
commit 948cda0a068dd2a1f9291be2b1292018cb35acaa
Author: Eric Schulte <address@hidden>
Date: Sun May 20 12:52:08 2012 -0400
parsing large complex files
---
sgf.el | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/sgf.el b/sgf.el
index 08611a1..66b9185 100644
--- a/sgf.el
+++ b/sgf.el
@@ -149,16 +149,15 @@
(defun closing-paren (str &optional index)
;; return index of closing paren watching out for []
(save-match-data
- (let ((paren-open 0)
- (square-open 0))
+ (let ((paren-open 0) (square-open 0) char last)
(loop for n from (or index 0) to (1- (length str))
- do (let ((last (when (> n 0) (aref str (1- n))))
- (char (aref str n)))
- (cond
- ((= char ?\[) (incf square-open))
- ((and (= char ?\]) (not (= last ?\\))) (decf square-open))
- ((and (= char ?\() (zerop square-open)) (incf paren-open))
- ((and (= char ?\)) (zerop square-open)) (decf paren-open))))
+ do
+ (setq last char char (aref str n))
+ (cond
+ ((and (= char ?\[) (not (= last ?\\))) (incf square-open))
+ ((and (= char ?\]) (not (= last ?\\))) (decf square-open))
+ ((and (= char ?\() (zerop square-open)) (incf paren-open))
+ ((and (= char ?\)) (zerop square-open)) (decf paren-open)))
when (zerop paren-open) return (1+ n)))))
(defun parse-trees (str)
@@ -171,9 +170,10 @@
(if cont-p
(let* ((start (1- m-end))
(end (closing-paren str start)))
+ (unless end (error "sgf: parsing w/o end at %d" start))
(collect (parse-trees (substring str start end)))
(1+ end))
- m-end))))))
+ m-end))))))
(defun read-from-buffer (buffer)
(process (parse-trees (with-current-buffer buffer (buffer-string)))))
- [elpa] 40/255: parsing empty properties, (continued)
- [elpa] 40/255: parsing empty properties, Eric Schulte, 2014/03/15
- [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 <=
- [elpa] 39/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 50/255: whitespace, Eric Schulte, 2014/03/15
- [elpa] 41/255: simplified parse-tree, but not done, Eric Schulte, 2014/03/15
- [elpa] 53/255: passing all tests, Eric Schulte, 2014/03/15
- [elpa] 54/255: more parsing/syntax tweaks, Eric Schulte, 2014/03/15
- [elpa] 56/255: some utility functions, Eric Schulte, 2014/03/15
- [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