emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 03/255: parse-prop -> parse-props


From: Eric Schulte
Subject: [elpa] 03/255: parse-prop -> parse-props
Date: Sun, 16 Mar 2014 01:02:08 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit 5325f5d627ddfdfd562fd92d3340f3ec64d75325
Author: Eric Schulte <address@hidden>
Date:   Tue May 15 06:53:45 2012 -0400

    parse-prop -> parse-props
---
 sgf.el |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/sgf.el b/sgf.el
index ba613ba..82b027b 100644
--- a/sgf.el
+++ b/sgf.el
@@ -53,15 +53,12 @@
 
 (defun parse-props (str)
   (let (res (start 0))
-    (while (string-match "[[:space:]]*;\\([[:alpha:]]+\\(\\[[^;]+?\\]\\)+\\)" 
str start)
+    (while (string-match "[[:space:]]*\\([[:alpha:]]+\\(\\[[^;]+?\\]\\)+\\)" 
str start)
       (setq start (match-end 0))
-      (push (parse-prop (match-string 1 str)) res))
+      (multiple-value-bind (id rest) (parse-prop-ident (match-string 1 str))
+        (push (cons id (parse-prop-vals rest)) res)))
     (nreverse res)))
 
-(defun parse-prop (str)
-  (multiple-value-bind (id rest) (parse-prop-ident str)
-    (cons id (parse-prop-vals rest))))
-
 (defun parse-prop-ident (str)
   (let ((end (if (and (<= ?A (aref str 1))
                       (< (aref str 1) ?Z))
@@ -76,21 +73,21 @@
       (push (match-string 1 str) res))
     (nreverse res)))
 
-(defun parse-node ())
+(defun parse-nodes ())
 
 
 ;;; Tests
 (require 'ert)
 
-(ert-deftest parse-prop-tests ()
+(ert-deftest sgf-parse-prop-tests ()
   (flet ((should= (a b) (should (tree-equal a b :test #'string=))))
-    (should= (parse-prop "B[pq]") '("B" "pq"))
-    (should= (parse-prop "GM[1]") '("GM" "1"))
-    (should (= (length (cdr (parse-prop "TB[as][bs][cq][cr][ds][ep]")))
+    (should= (parse-props "B[pq]") '(("B" "pq")))
+    (should= (parse-props "GM[1]") '(("GM" "1")))
+    (should (= (length (cdar (parse-props "TB[as][bs][cq][cr][ds][ep]")))
                6))))
 
-(ert-deftest parse-nodes-test ()
+(ert-deftest sgf-parse-nodes-test ()
   (let* ((str ";B[pq];W[dd];B[pc];W[eq];B[cp];W[cm];B[do];W[hq];B[qn];W[cj]")
-         (nodes (parse-props str)))
+         (nodes (parse-nodes str)))
     (should (= (length nodes) 10))
     (should (tree-equal (car nodes) '("B" "pq") :test #'string=))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]