blob: b537c866a1b68f6b5fea0335e659730c87260549 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
(fn must [...]
(local (ok? result) ...)
(if ok? result (error result)))
(fn measure [what f]
(local start (must (luna.time.now)))
(local res (table.pack (f)))
(print (.. what ": " (/ (- (must (luna.time.now)) start) 1e6)))
(values (table.unpack res)))
(fn test-peg [file peg]
(local parser (require :parser.parser))
(with-open [f (io.open file "r")]
(local contents (f:read :*all))
(local items (parser.match-many contents peg))
(when items
(print (.. "count: " (# items))))
(print (fennel.view items)))
(os.exit 1))
{: must : measure : test-peg}
|