forked from panicz/grasp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
play-test.scm
68 lines (58 loc) · 1.66 KB
/
play-test.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(import (kawa regex))
(import (only (srfi :1) partition span break first second))
(import (srfi :11))
(import (utils shell))
(import (utils functions))
(import (language infix))
(import (language match))
(import (utils hash-table))
(import (language mapping))
(import (language for))
;;(import (editor term))
(define (matching string pattern)
(regex-match pattern string))
(define files '())
(define options '())
(define step-time/seconds 1)
(define interactive? #f)
(match (command-line)
(`(,command . ,args)
(let-values (((command-line-options given-files)
(partition (is _ matching "^--") args)))
(set! options command-line-options)
(set! files given-files))))
(and-let* ((`(,_ ,time)
(any (is _ matching "^--step-time=\([0-9]+[.]?[0-9]*\)$")
options)))
(set! step-time/seconds (string->number time)))
(when (any (is _ equal? "--interactive") options)
(set! interactive? #t))
(define contents
(map (lambda (file)
(let ((expressions (with-input-from-file file read-all)))
(let-values (((_prefix contents)
(break (lambda (e)
(and-let* ((`(snapshot ,screen) e))))
expressions)))
`(,file . ,contents))))
files))
(for entry in contents
(display (car entry))
(newline)
(let loop ((expressions (cdr entry)))
(when (isnt expressions null?)
(match expressions
(`((snapshot ,screen) . ,rest)
(display screen)
(newline)
(sleep step-time/seconds)
(let-values (((operations next)
(break (lambda (e)
(and-let* ((`(snapshot ,screen)
e))))
rest)))
#;(for operation in operations
(write operation))
;(newline)
;;(sleep step-time/seconds)
(loop next)))))))