1 ;;; test-lr-basics-01.scm --
3 ;;A grammar that only accept a single terminal as input. It refuses the
4 ;;end-of-input as first token.
7 (load "common-test.scm")
9 (define (doit . tokens)
10 (let* ((lexer (make-lexer tokens))
11 (parser (lalr-parser (expect: 0)
14 (parser lexer error-handler)))
17 (doit (make-lexical-token 'A #f 1))
23 => '(#f (error-handler "Syntax error: unexpected end of input")))
26 ;;Parse correctly the first A and reduce it. The second A triggers
27 ;;an error which empties the stack and consumes all the input
28 ;;tokens. Finally, an unexpected end-of-input error is returned
29 ;;because EOI is invalid as first token after the start.
30 (let ((r (doit (make-lexical-token 'A #f 1)
31 (make-lexical-token 'A #f 2)
32 (make-lexical-token 'A #f 3))))
35 (error-handler "Syntax error: unexpected end of input")
36 (error-handler "Syntax error: unexpected token : " . A)))