Skip to content

Commit ac3cce9

Browse files
committed
Rudimentary stepper.
1 parent 59802fa commit ac3cce9

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

langs/a86/stepper.rkt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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))))

0 commit comments

Comments
 (0)