From 7b92cdd9d4e4b1cabe7093f818707af04e4bdda2 Mon Sep 17 00:00:00 2001 From: unwox Date: Wed, 6 Nov 2024 23:48:28 +0600 Subject: add test-peg function for a quick parsers debugging --- lib/utils.fnl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/utils.fnl') diff --git a/lib/utils.fnl b/lib/utils.fnl index 917f4af..046f646 100644 --- a/lib/utils.fnl +++ b/lib/utils.fnl @@ -8,4 +8,12 @@ (print (.. what ": " (/ (- (must (luna.time.now)) start) 1e6))) (values (table.unpack res))) -{: must : measure} +(fn test-peg [file peg] + (local fennel (require :vendor.fennel)) + (local parser (require :parser.parser)) + (with-open [f (io.open file "r")] + (local contents (f:read :*all)) + (print (fennel.view (parser.match-many contents peg)))) + (os.exit 1)) + +{: must : measure : test-peg} -- cgit v1.2.3