Skip to content

Commit 317437a

Browse files
wilbowmarfindler
authored andcommitted
Add rule names to runtime judgment form, for stepper support
Add the list of rule names to the runtime judgment form struct, so the stepper can support displaying rule names in the reduction name label, and "run" a judgment until a specific rule.
1 parent af7187b commit 317437a

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

redex-gui-lib/redex/private/stepper.rkt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ todo:
132132
[editor zoom-out-pb]))
133133

134134
(define choice-vp (new vertical-panel% [alignment '(center center)] [parent lower-hp] [stretchable-width #f]))
135-
(define reduction-names (if (IO-judgment-form? red)
136-
'()
137-
(reduction-relation->rule-names red)))
135+
(define reduction-names (reduction-relation/IO-jf->rule-names red))
136+
138137
(define reds-choice
139138
(and (not (null? reduction-names))
140139
(new choice%

redex-lib/redex/private/judgment-form.rkt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
compiled-input-contract-pat
4545
compiled-output-contract-pat
4646
input-contract-pat
47-
output-contract-pat)
47+
output-contract-pat
48+
rule-names)
4849
#:methods gen:custom-write
4950
[(define (write-proc rjf port _mode)
5051
(if (runtime-judgment-form-mode rjf)
@@ -66,7 +67,8 @@
6667
name proc mode lang
6768
original-contract-expression ;; (or/c #f (listof s-exp))
6869
input-contract-pat
69-
output-contract-pat)
70+
output-contract-pat
71+
(rule-names '()))
7072
(define cache (cons (box (make-hash)) (box (make-hash))))
7173
(make-runtime-judgment-form
7274
name proc mode cache lang
@@ -98,7 +100,15 @@
98100
(runtime-judgment-form-input-contract-pat parent-judgment-form)))
99101
(or output-contract-pat
100102
(and parent-judgment-form
101-
(runtime-judgment-form-output-contract-pat parent-judgment-form)))))
103+
(runtime-judgment-form-output-contract-pat parent-judgment-form)))
104+
(map (lambda (raw-name)
105+
(cond
106+
[raw-name => (lambda (x)
107+
(if (symbol? x)
108+
x
109+
(string->symbol x)))]
110+
[else raw-name]))
111+
rule-names)))
102112

103113
(define-for-syntax (prune-syntax stx)
104114
(datum->syntax
@@ -939,7 +949,8 @@
939949
#,lang
940950
original-contract-expression
941951
judgment-form-input-contract
942-
judgment-form-output-contract))
952+
judgment-form-output-contract
953+
'#,rule-names))
943954
(define jf-cache (runtime-judgment-form-cache the-runtime-judgment-form))
944955
(define original-contract-expression-id
945956
(runtime-judgment-form-original-contract-expression the-runtime-judgment-form))

redex-lib/redex/private/reduction-semantics.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2871,7 +2871,7 @@
28712871
(define (reduction-relation/IO-jf->rule-names x)
28722872
(cond
28732873
[(reduction-relation? x) (reduction-relation->rule-names x)]
2874-
[(IO-judgment-form? x) '(judgment-form->rule-names x)]))
2874+
[(IO-judgment-form? x) (runtime-judgment-form-rule-names x)]))
28752875

28762876

28772877
;
@@ -3361,6 +3361,7 @@
33613361
(provide (rename-out [-reduction-relation reduction-relation])
33623362
::=
33633363
reduction-relation->rule-names
3364+
reduction-relation/IO-jf->rule-names
33643365
reduction-relation/IO-jf-lang
33653366
extend-reduction-relation
33663367
reduction-relation?

0 commit comments

Comments
 (0)