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