|
|
|
@ -8,6 +8,7 @@
|
|
|
|
|
;; - (make-reduce prod runtime-action)
|
|
|
|
|
;; - (make-accept)
|
|
|
|
|
;; - (make-goto int)
|
|
|
|
|
;; - (no-action)
|
|
|
|
|
;; A reduce contains a runtime-reduce so that sharing of the reduces can
|
|
|
|
|
;; be easily transferred to sharing of runtime-reduces.
|
|
|
|
|
|
|
|
|
@ -16,6 +17,7 @@
|
|
|
|
|
(define-struct (reduce action) (prod runtime-reduce) (make-inspector))
|
|
|
|
|
(define-struct (accept action) () (make-inspector))
|
|
|
|
|
(define-struct (goto action) (state) (make-inspector))
|
|
|
|
|
(define-struct (no-action action) () (make-inspector))
|
|
|
|
|
|
|
|
|
|
(define (make-reduce* p)
|
|
|
|
|
(make-reduce p
|
|
|
|
@ -28,13 +30,15 @@
|
|
|
|
|
;; (vector int symbol int) (reduce)
|
|
|
|
|
;; 'accept (accept)
|
|
|
|
|
;; negative-int (goto)
|
|
|
|
|
;; #f (no-action)
|
|
|
|
|
|
|
|
|
|
(define (action->runtime-action a)
|
|
|
|
|
(cond
|
|
|
|
|
((shift? a) (shift-state a))
|
|
|
|
|
((reduce? a) (reduce-runtime-reduce a))
|
|
|
|
|
((accept? a) 'accept)
|
|
|
|
|
((goto? a) (- (+ (goto-state a) 1)))))
|
|
|
|
|
((goto? a) (- (+ (goto-state a) 1)))
|
|
|
|
|
((no-action? a) #f)))
|
|
|
|
|
|
|
|
|
|
(define (runtime-shift? x) (and (integer? x) (>= x 0)))
|
|
|
|
|
(define runtime-reduce? vector?)
|
|
|
|
|