File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #lang racket
2+ (provide main)
3+
4+ (require redex)
5+
6+ (define-language L)
7+
8+ ;; A reduction relation that just relates elements
9+ ;; of the list to their successors
10+ (define (r ls)
11+ (define i 0 )
12+ (reduction-relation L
13+ (--> any_i
14+ any_j
15+ (where any_j
16+ ,(begin
17+ (set! i (add1 i))
18+ (list-ref ls (min i (sub1 (length ls)))))))))
19+
20+
21+ ;; reads log file from stdin
22+ (define (main)
23+ (define ls
24+ (let loop ()
25+ (if (eof-object? (read))
26+ '()
27+ (cons (read) (loop)))))
28+
29+ ;; replace instr indices with their instructions
30+ (define ls1
31+ (map (λ (s)
32+ (map (λ (p)
33+ (match p
34+ [(list 'instr i)
35+ (list 'instr (list-ref (list-ref ls 0 )
36+ (add1 i)))]
37+ [_ p]))
38+ s))
39+ ls))
40+
41+ ;; run the stepper
42+ (stepper (r (rest ls1)) (first (rest ls1))))
You can’t perform that action at this time.
0 commit comments