From 04bce78b13249ebc0233b84c4971a2f86f462191 Mon Sep 17 00:00:00 2001 From: Greg Sexton Date: Mon, 7 Apr 2014 21:50:39 +0100 Subject: [PATCH] Add many parser --- origami.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/origami.el b/origami.el index 0eb86b0..3e1c645 100644 --- a/origami.el +++ b/origami.el @@ -217,11 +217,21 @@ used to nil out data. This mutates the node." (end <- end) (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-parser-paired (origami-parser-char "{") - (origami-parser-char "}") - (origami-parser-return nil)) - (origami-content 7 "{}")) + (origami-parser-many (origami-parser-paired (origami-parser-char "{") + (origami-parser-char "}") + (origami-parser-return nil))) + (origami-content 7 "{}{}{}{}{}")) ;;; TODO: rework this (defun origami-parse (buffer parser) @@ -229,6 +239,8 @@ used to nil out data. This mutates the node." (let ((contents (buffer-string))) (origami-run-parser parser (origami-content 0 contents))))) +;;; dsl + ;;; commands (defun origami-reset (buffer)