finish yaml gen

This commit is contained in:
2025-08-31 14:59:37 +02:00
parent f1be675f10
commit 8d18875697
3 changed files with 57 additions and 20 deletions

71
yaml.0.lsp Normal file
View File

@@ -0,0 +1,71 @@
(:macro seq ())
(:macro c-not ( c )
)
; works because this has a higher constraints score:
(:macro c-not ( (c (:c-eq () _)) )
())
(:macro seq-exp (hd)
(':ot (':str-cat "- " (':t2ot-elt hd))))
(:macro seq-exp (hd .. tl)
(':seq-exp hd) (':seq-exp tl))
(:macro seq (hd)
(':seq-exp hd))
(:macro seq (hd .. tl)
(':seq-exp hd tl))
(:macro c-paren-eval (x)
(':c-atm x)
(':c-not (':c-colon-id x)))
(:macro @ ( (k(:c-paren-eval _)) )
(':t (':str-cat (':t2ot-elt k) ":")))
(:macro @ ( (k(:c-paren-eval _)) v )
(':t (':dict-key (':atm-to-str k)) v))
(:macro @ ( (k(:c-paren-eval _)) (v(:c-paren-eval _)) )
(':t (':str-cat (':str-cat (':atm-to-str k) ": ") (':atm-to-str v) )))
(:macro @ ( (k(:c-paren-eval _)) v .. other)
(':t (':dict-key (':atm-to-str k)) v other))
(:macro t2ot-elt ( hd )
(':atm-to-str hd))
(:macro t2ot-elt ( hd .. tl )
(':tree
(':t2ot-elt hd)
(':t2ot-elt tl)))
(:macro t ()
(':ot))
(:macro t ( .. tl )
(':ot
(':t2ot-elt tl)))
(:macro ot ( x )
(':yot (':indent x)))
(:macro indent-each ())
(:macro indent-each ( hd )
(':indent hd))
(:macro indent-each ( hd .. tl )
(':indent-each hd)
(':indent-each tl))
(:macro rm-first (x .. tl)
tl)
;(:macro indent ( (x(:c-str _)) )
; (':str-cat " " x))
(:macro indent ( (x(:c-li0-eq _ :tree)) )
(':tree (':indent-each (':rm-first (':unpack x)))))
(:macro indent ( (x(:c-li0-eq _ :atm-to-str)) )
(':atm-to-str (':indent-each (':rm-first (':unpack x)))))
(:macro indent ( (x(:c-li0-eq _ :yot)) )
(':yot (':indent-each (':rm-first (':unpack x)))))
(:macro indent ( (x(:c-li0-eq _ :dict-key)) )
(':dict-key (':indent-each (':rm-first (':unpack x)))))