commit 6acfa72dd92e59faaf158aa92514e48b61d7419d parent b79b89b296a14b38fe0945ab131985f6138e4e34 Author: Szymon Mikulicz <szymon.mikulicz@posteo.net> Date: Fri, 22 May 2026 19:16:27 +0200 Add mnt parser start Diffstat:
| A | src/mnt.janet | | | 19 | +++++++++++++++++++ |
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/mnt.janet b/src/mnt.janet @@ -0,0 +1,19 @@ +(def base_indent 2) + +(defn inc_indent [x] + (+ x base_indent)) + +(def mnt_peg + (peg/compile + ~{ + :main (* (only-tags (constant 0 :col)) :map) + :key (+ :check_indent (<- (to ":"))) + :val (* " " (+ :check_key_start (* (<- (to (+ " \n" "\n" -1))) (+ :check_key_end true)))) + :pair (* :key ":" (+ (* :val (? "\n")) "\n")) + :increase (only-tags (/ (backref :col) ,inc_indent :col)) + :indent (lenprefix (backref :col) " ") + :map (any (group (unref (* :indent :pair :increase :map) :col))) + :check_indent (error (* " " (constant "Invalid indent"))) + :check_key_start (error (* (+ " " "\n") (constant "Key starting with space"))) + :check_key_end (error (* " " (constant "Key ends with space"))) + }))