summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-11-06 23:48:28 +0600
committerunwox <me@unwox.com>2024-11-06 23:48:28 +0600
commit7b92cdd9d4e4b1cabe7093f818707af04e4bdda2 (patch)
tree11a8c679ce178d2b0b11950a036edb57e3aaad5a /lib
parent9d5e8f6a202da9d0e2f1a7cee93b7fb2ec518e2c (diff)
add test-peg function for a quick parsers debugging
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.fnl10
1 files changed, 9 insertions, 1 deletions
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}