1 ;;; test-lr-basics-02.scm --
3 ;;A grammar that only accept a single terminal or the EOI.
6 (load "common-test.scm")
8 (define (doit . tokens)
9 (let ((parser (lalr-parser (expect: 0)
13 (parser (make-lexer tokens) error-handler)))
20 (doit (make-lexical-token 'A #f 1))
24 ;;Parse correctly the first A and reduce it. The second A triggers
25 ;;an error which empties the stack and consumes all the input
26 ;;tokens. Finally, the end-of-input token is correctly parsed.
27 (let ((r (doit (make-lexical-token 'A #f 1)
28 (make-lexical-token 'A #f 2)
29 (make-lexical-token 'A #f 3))))
31 => '(0 (error-handler "Syntax error: unexpected token : " . A)))