[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b4fff55 23/46: tiny.el: fixed `tiny-tokenize'
From: |
Oleh Krehel |
Subject: |
[elpa] master b4fff55 23/46: tiny.el: fixed `tiny-tokenize' |
Date: |
Sun, 22 Mar 2015 17:42:32 +0000 |
branch: master
commit b4fff553ea4806849eeb9f5f08009d7b0ed3c31e
Author: oleh <address@hidden>
Commit: oleh <address@hidden>
tiny.el: fixed `tiny-tokenize'
Added a bunch of tests as well.
---
tiny.el | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/tiny.el b/tiny.el
index 7f03d94..b2dd391 100644
--- a/tiny.el
+++ b/tiny.el
@@ -300,12 +300,9 @@ Return nil if nothing was matched, otherwise
(defun tiny-tokenize (str)
(unless (equal str "")
(ignore-errors
- (let ((i 0)
- (j 1)
+ (let ((i 0) (j 1)
(len (length str))
- sym
- s
- out
+ sym s out allow-spc
(n-paren 0)
(expect-fun t))
(while (< i len)
@@ -314,11 +311,11 @@ Return nil if nothing was matched, otherwise
((string= s "x")
(push s out)
(push " " out))
- ((string= s "y")
- (push s out)
- (push " " out))
((string= s " ")
- (error "unexpected \" \""))
+ (if allow-spc
+ t
+ (error "unexpected \" \"")))
+ ;; special syntax to read chars
((string= s "?")
(setq s (format "%s" (read (substring str i (incf j)))))
(push s out)
@@ -330,10 +327,12 @@ Return nil if nothing was matched, otherwise
(error "unexpected \")\""))
(when (string= (car out) " ")
(pop out))
- (push ") " out))
+ (push ")" out)
+ (push " " out))
((string= s "(")
;; open paren is used sometimes
;; when there are numbers in the expression
+ (setq expect-fun t)
(incf n-paren)
(push "(" out))
((progn (setq sym (intern-soft s))
@@ -341,10 +340,12 @@ Return nil if nothing was matched, otherwise
;; general functionp
((not (eq t (help-function-arglist sym)))
(setq expect-fun)
- ;; (when (zerop n-paren)
- ;; (push "(" out))
- (push "(" out)
- (incf n-paren))
+ (setq allow-spc t)
+ ;; (when (zerop n-paren) (push "(" out))
+ (unless (equal (car out) "(")
+ (push "(" out)
+ (incf n-paren))
+ t)
((and sym (boundp sym) (not expect-fun))
t)))
(push s out)
- [elpa] master 067e820 11/46: tiny.el: improved `tiny-mapconcat` and `tiny-mapconcat-parse'., (continued)
- [elpa] master 067e820 11/46: tiny.el: improved `tiny-mapconcat` and `tiny-mapconcat-parse'., Oleh Krehel, 2015/03/22
- [elpa] master cad8e50 13/46: tiny.el: added the option to include %(sexps) into the format string., Oleh Krehel, 2015/03/22
- [elpa] master 78241c4 15/46: tiny.el: fixed a bug for expansion of m5%x., Oleh Krehel, 2015/03/22
- [elpa] master 29b5b76 16/46: Added README.md, Oleh Krehel, 2015/03/22
- [elpa] master b9c35e1 17/46: README.md: minor update., Oleh Krehel, 2015/03/22
- [elpa] master 97b9fdf 14/46: tiny.el: fixed up the previous change., Oleh Krehel, 2015/03/22
- [elpa] master 80e64b8 18/46: README.md: minor update., Oleh Krehel, 2015/03/22
- [elpa] master 2bd9abb 21/46: tiny.el: moved tests to tiny-test.el., Oleh Krehel, 2015/03/22
- [elpa] master b99315d 20/46: tiny.el: updated the doc., Oleh Krehel, 2015/03/22
- [elpa] master 11722a1 19/46: tiny.el: fixed typos., Oleh Krehel, 2015/03/22
- [elpa] master b4fff55 23/46: tiny.el: fixed `tiny-tokenize',
Oleh Krehel <=
- [elpa] master 5df4f79 25/46: tiny.el: removed `tiny-beginning-of-string', Oleh Krehel, 2015/03/22
- [elpa] master 8a3cab0 27/46: tiny.el: removed `tiny-replace-preceding-sexp', Oleh Krehel, 2015/03/22
- [elpa] master f1d1a2e 22/46: tiny-test.el: switched to ERT., Oleh Krehel, 2015/03/22
- [elpa] master 4c87ade 29/46: tiny.el: fixed a bug in `tiny-mapconcat-parse'., Oleh Krehel, 2015/03/22
- [elpa] master a6e4144 30/46: tiny.el (tiny-extract-sexps): can handle e.g. %0.1f(...) style formatting., Oleh Krehel, 2015/03/22
- [elpa] master 80cd28f 28/46: tiny-test.el: added a test for `tiny-replace-this-sexp', Oleh Krehel, 2015/03/22
- [elpa] master 08ba593 24/46: tiny.el: fixed `tiny-tokenize', Oleh Krehel, 2015/03/22
- [elpa] master e6abbc6 31/46: tiny.el (tiny-date): renamed from t-date. In format string it's just "date", Oleh Krehel, 2015/03/22
- [elpa] master c59bc94 36/46: tiny.el (tiny-extract-sexps): add missing let binding, Oleh Krehel, 2015/03/22
- [elpa] master cf74dd1 34/46: tiny.el: fix docs, Oleh Krehel, 2015/03/22