Add many parser
This commit is contained in:
parent
7bf9c22e47
commit
04bce78b13
20
origami.el
20
origami.el
@ -217,11 +217,21 @@ used to nil out data. This mutates the node."
|
|||||||
(end <- end)
|
(end <- end)
|
||||||
(origami-parser-return (origami-fold-node begin end t children))))
|
(origami-parser-return (origami-fold-node begin end t children))))
|
||||||
|
|
||||||
|
(defun origami-parser-many (p)
|
||||||
|
;; recursive isn't going to cut it in elisp
|
||||||
|
(lambda (content)
|
||||||
|
(let ((res (origami-run-parser p content))
|
||||||
|
(acc nil))
|
||||||
|
(while res
|
||||||
|
(setq acc (cons (car res) acc))
|
||||||
|
(setq res (origami-run-parser p (cdr res))))
|
||||||
|
(reverse acc))))
|
||||||
|
|
||||||
(origami-run-parser
|
(origami-run-parser
|
||||||
(origami-parser-paired (origami-parser-char "{")
|
(origami-parser-many (origami-parser-paired (origami-parser-char "{")
|
||||||
(origami-parser-char "}")
|
(origami-parser-char "}")
|
||||||
(origami-parser-return nil))
|
(origami-parser-return nil)))
|
||||||
(origami-content 7 "{}"))
|
(origami-content 7 "{}{}{}{}{}"))
|
||||||
|
|
||||||
;;; TODO: rework this
|
;;; TODO: rework this
|
||||||
(defun origami-parse (buffer parser)
|
(defun origami-parse (buffer parser)
|
||||||
@ -229,6 +239,8 @@ used to nil out data. This mutates the node."
|
|||||||
(let ((contents (buffer-string)))
|
(let ((contents (buffer-string)))
|
||||||
(origami-run-parser parser (origami-content 0 contents)))))
|
(origami-run-parser parser (origami-content 0 contents)))))
|
||||||
|
|
||||||
|
;;; dsl
|
||||||
|
|
||||||
;;; commands
|
;;; commands
|
||||||
|
|
||||||
(defun origami-reset (buffer)
|
(defun origami-reset (buffer)
|
||||||
|
Loading…
Reference in New Issue
Block a user