diff options
| author | unwox <me@unwox.com> | 2024-11-06 23:48:28 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-11-06 23:48:28 +0600 |
| commit | 7b92cdd9d4e4b1cabe7093f818707af04e4bdda2 (patch) | |
| tree | 11a8c679ce178d2b0b11950a036edb57e3aaad5a /lib | |
| parent | 9d5e8f6a202da9d0e2f1a7cee93b7fb2ec518e2c (diff) | |
add test-peg function for a quick parsers debugging
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/utils.fnl | 10 |
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} |
