Simplify test parser
This commit is contained in:
parent
26e35f4227
commit
bdc0815218
26
origami.el
26
origami.el
@ -396,8 +396,9 @@ recursion. We fail if we don't consume something."
|
|||||||
(origami-run-parser (origami-parser-item) content))))
|
(origami-run-parser (origami-parser-item) content))))
|
||||||
|
|
||||||
(defun origami-parser-paired (start children end create)
|
(defun origami-parser-paired (start children end create)
|
||||||
"CHILDREN should be a zero-arg lambda returning a parser to
|
;; TODO: make this a macro so I don't have to pass in the thunk?
|
||||||
allow for recursive nesting."
|
"CHILDREN should be a zero-arg lambda -- a thunk -- returning a
|
||||||
|
parser to allow for recursive nesting of a parser."
|
||||||
(origami-do (begin <- start)
|
(origami-do (begin <- start)
|
||||||
(children <- (funcall children))
|
(children <- (funcall children))
|
||||||
(end <- end)
|
(end <- end)
|
||||||
@ -433,18 +434,15 @@ allow for recursive nesting."
|
|||||||
origami-fold-root-node)))))
|
origami-fold-root-node)))))
|
||||||
|
|
||||||
(defun origami-test-parser (create)
|
(defun origami-test-parser (create)
|
||||||
(origami-parser-0+ (origami-parser-conj
|
(let ((pair (origami-parser-paired (origami-parser-char "{")
|
||||||
(origami-do
|
(lambda () (origami-test-parser create))
|
||||||
(origami-parser-drop-until-regex "[{}]")
|
(origami-parser-char "}")
|
||||||
(origami-parser-1?
|
create)))
|
||||||
(origami-parser-paired (origami-parser-char "{")
|
(origami-parser-0+ (origami-parser-conj
|
||||||
(lambda () (origami-test-parser create))
|
(origami-do
|
||||||
(origami-parser-char "}")
|
(origami-parser-drop-until-regex "[{}]")
|
||||||
create)))
|
(origami-parser-1? pair))
|
||||||
(origami-parser-paired (origami-parser-char "{")
|
pair))))
|
||||||
(lambda () (origami-test-parser create))
|
|
||||||
(origami-parser-char "}")
|
|
||||||
create))))
|
|
||||||
|
|
||||||
(defun origami-get-parser (buffer)
|
(defun origami-get-parser (buffer)
|
||||||
;; TODO: remove hardcoding!
|
;; TODO: remove hardcoding!
|
||||||
|
Loading…
Reference in New Issue
Block a user