|
|
@ -214,7 +214,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
(fix-error
|
|
|
|
(fix-error
|
|
|
|
(lambda (stack tok ip get-token)
|
|
|
|
(lambda (stack tok ip get-token)
|
|
|
|
(printf "stack: ~a~n" stack)
|
|
|
|
;;(printf "stack: ~a~n" stack)
|
|
|
|
(letrec ((remove-input
|
|
|
|
(letrec ((remove-input
|
|
|
|
(lambda ()
|
|
|
|
(lambda ()
|
|
|
|
(if (memq (token-name tok) ends)
|
|
|
|
(if (memq (token-name tok) ends)
|
|
|
@ -223,7 +223,7 @@
|
|
|
|
(let ((a (find-action stack tok ip)))
|
|
|
|
(let ((a (find-action stack tok ip)))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((shift? a)
|
|
|
|
((shift? a)
|
|
|
|
(printf "shift:~a~n" (shift-state a))
|
|
|
|
;;(printf "shift:~a~n" (shift-state a))
|
|
|
|
(cons (if src-pos
|
|
|
|
(cons (if src-pos
|
|
|
|
(make-stack-frame (shift-state a)
|
|
|
|
(make-stack-frame (shift-state a)
|
|
|
|
(token-value tok)
|
|
|
|
(token-value tok)
|
|
|
@ -235,7 +235,7 @@
|
|
|
|
#f))
|
|
|
|
#f))
|
|
|
|
stack))
|
|
|
|
stack))
|
|
|
|
(else
|
|
|
|
(else
|
|
|
|
(printf "discard input:~a~n" tok)
|
|
|
|
;;(printf "discard input:~a~n" tok)
|
|
|
|
(set! ip (get-token))
|
|
|
|
(set! ip (get-token))
|
|
|
|
(set! tok (input->token ip))
|
|
|
|
(set! tok (input->token ip))
|
|
|
|
(remove-input)))))))
|
|
|
|
(remove-input)))))))
|
|
|
@ -244,7 +244,7 @@
|
|
|
|
(let ((a (find-action stack (make-token 'error #f) ip)))
|
|
|
|
(let ((a (find-action stack (make-token 'error #f) ip)))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((shift? a)
|
|
|
|
((shift? a)
|
|
|
|
(printf "shift:~a~n" (shift-state a))
|
|
|
|
;;(printf "shift:~a~n" (shift-state a))
|
|
|
|
(set! stack
|
|
|
|
(set! stack
|
|
|
|
(cons
|
|
|
|
(cons
|
|
|
|
(if src-pos
|
|
|
|
(if src-pos
|
|
|
@ -259,7 +259,7 @@
|
|
|
|
stack))
|
|
|
|
stack))
|
|
|
|
(remove-input))
|
|
|
|
(remove-input))
|
|
|
|
(else
|
|
|
|
(else
|
|
|
|
(printf "discard state:~a~n" (car stack))
|
|
|
|
;;(printf "discard state:~a~n" (car stack))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((< (length stack) 2)
|
|
|
|
((< (length stack) 2)
|
|
|
|
(raise-read-error "parser: Cannot continue after error"
|
|
|
|
(raise-read-error "parser: Cannot continue after error"
|
|
|
|