|
|
@ -68,8 +68,8 @@
|
|
|
|
(lambda (s n v)
|
|
|
|
(lambda (s n v)
|
|
|
|
(if (> n 0)
|
|
|
|
(if (> n 0)
|
|
|
|
,(if src-pos
|
|
|
|
,(if src-pos
|
|
|
|
`(reduce-stack (cddr s) (sub1 n) `(,(cadr s) ,(caddr s) ,(cadddr s) ,@v))
|
|
|
|
`(reduce-stack (cddddr s) (sub1 n) `(,(cadr s) ,(caddr s) ,(cadddr s) ,@v))
|
|
|
|
`(reduce-stack (cddr s) (sub1 n) (cons (cadr s) v)))
|
|
|
|
`(reduce-stack (cddddr s) (sub1 n) (cons (cadr s) v)))
|
|
|
|
(values s v))))
|
|
|
|
(values s v))))
|
|
|
|
(fix-error
|
|
|
|
(fix-error
|
|
|
|
(lambda (stack ip get-token)
|
|
|
|
(lambda (stack ip get-token)
|
|
|
@ -111,6 +111,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
(find-action
|
|
|
|
(find-action
|
|
|
|
(lambda (stack tok)
|
|
|
|
(lambda (stack tok)
|
|
|
|
|
|
|
|
;; (display (if (token? tok) (token-name tok) tok))
|
|
|
|
|
|
|
|
;; (newline)
|
|
|
|
(array2d-ref table
|
|
|
|
(array2d-ref table
|
|
|
|
(car stack)
|
|
|
|
(car stack)
|
|
|
|
(hash-table-get term-sym->index
|
|
|
|
(hash-table-get term-sym->index
|
|
|
@ -124,10 +126,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
;; (display stack)
|
|
|
|
;; (display stack)
|
|
|
|
;; (newline)
|
|
|
|
;; (newline)
|
|
|
|
;;(display (if (token? ip) (token-name ip) ip))
|
|
|
|
|
|
|
|
;;(newline)
|
|
|
|
|
|
|
|
(let* ((tok ,(if src-pos `(car ip) `ip))
|
|
|
|
(let* ((tok ,(if src-pos `(car ip) `ip))
|
|
|
|
(action (find-action stack tok)))
|
|
|
|
(action (find-action stack tok)))
|
|
|
|
|
|
|
|
;; (display (if (token? tok) (token-name tok) tok))
|
|
|
|
|
|
|
|
;; (newline)
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((shift? action)
|
|
|
|
((shift? action)
|
|
|
|
;; (printf "shift:~a~n" (shift-state action))
|
|
|
|
;; (printf "shift:~a~n" (shift-state action))
|
|
|
@ -146,12 +148,25 @@
|
|
|
|
null)))
|
|
|
|
null)))
|
|
|
|
(let* ((A (reduce-lhs-num action))
|
|
|
|
(let* ((A (reduce-lhs-num action))
|
|
|
|
(goto (array2d-ref table (car new-stack) A)))
|
|
|
|
(goto (array2d-ref table (car new-stack) A)))
|
|
|
|
(parsing-loop (cons goto
|
|
|
|
(parsing-loop ,(if src-pos
|
|
|
|
(cons (apply
|
|
|
|
``(,goto
|
|
|
|
|
|
|
|
,(apply
|
|
|
|
|
|
|
|
(vector-ref actions
|
|
|
|
|
|
|
|
(reduce-prod-num action))
|
|
|
|
|
|
|
|
args)
|
|
|
|
|
|
|
|
,(if (null? args)
|
|
|
|
|
|
|
|
(caddr new-stack)
|
|
|
|
|
|
|
|
(cadr args))
|
|
|
|
|
|
|
|
,(if (null? args)
|
|
|
|
|
|
|
|
(caddr new-stack)
|
|
|
|
|
|
|
|
(list-ref args (- (* (reduce-rhs-length action) 3) 1)))
|
|
|
|
|
|
|
|
,@new-stack)
|
|
|
|
|
|
|
|
``(,goto
|
|
|
|
|
|
|
|
,(apply
|
|
|
|
(vector-ref actions
|
|
|
|
(vector-ref actions
|
|
|
|
(reduce-prod-num action))
|
|
|
|
(reduce-prod-num action))
|
|
|
|
args)
|
|
|
|
args)
|
|
|
|
new-stack))
|
|
|
|
,@new-stack))
|
|
|
|
ip))))
|
|
|
|
ip))))
|
|
|
|
((accept? action)
|
|
|
|
((accept? action)
|
|
|
|
;; (printf "accept~n")
|
|
|
|
;; (printf "accept~n")
|
|
|
|