Run Resyntax again

remotes/jackfirth/master
Jack Firth 2 years ago
parent bac8fef8e4
commit c5a399ff62

@ -203,19 +203,19 @@
(define (fix-error stack tok val start-pos end-pos get-token) (define (fix-error stack tok val start-pos end-pos get-token)
(when debug? (pretty-print stack)) (when debug? (pretty-print stack))
(local ((define (remove-input tok val start-pos end-pos) (local ((define (remove-input tok val start-pos end-pos)
(if (memq tok ends) (when (memq tok ends)
(raise-read-error "parser: Cannot continue after error" (raise-read-error "parser: Cannot continue after error"
#f #f #f #f #f) #f #f #f #f #f))
(let ([a (find-action stack tok val start-pos end-pos)]) (define a (find-action stack tok val start-pos end-pos))
(cond (cond
[(runtime-shift? a) [(runtime-shift? a)
(cons (stack-frame (runtime-shift-state a) (cons (stack-frame (runtime-shift-state a)
val val
start-pos start-pos
end-pos) end-pos)
stack)] stack)]
[else [else
(call-with-values (λ () (extract (get-token))) remove-input)]))))) (call-with-values (λ () (extract (get-token))) remove-input)])))
(let remove-states () (let remove-states ()
(define a (find-action stack 'error #f start-pos end-pos)) (define a (find-action stack 'error #f start-pos end-pos))
(cond (cond
@ -228,14 +228,12 @@
end-pos) end-pos)
stack)) stack))
(remove-input tok val start-pos end-pos)] (remove-input tok val start-pos end-pos)]
[(< (length stack) 2)
(raise-read-error "parser: Cannot continue after error"
#f #f #f #f #f)]
[else [else
(cond (set! stack (cdr stack))
[(< (length stack) 2) (remove-states)]))))
(raise-read-error "parser: Cannot continue after error"
#f #f #f #f #f)]
[else
(set! stack (cdr stack))
(remove-states)])]))))
(define (find-action stack tok val start-pos end-pos) (define (find-action stack tok val start-pos end-pos)
(unless (hash-ref all-term-syms tok #f) (unless (hash-ref all-term-syms tok #f)

Loading…
Cancel
Save