Commit | Line | Data |
---|---|---|
1b101522 LC |
1 | ;;; test-lr-basics-03.scm -- |
2 | ;; | |
3 | ;;A grammar that accepts fixed sequences of a single terminal or the | |
4 | ;;EOI. | |
5 | ||
6 | (load "common-test.scm") | |
7 | ||
8 | (define (doit . tokens) | |
9 | (let ((parser (lalr-parser (expect: 0) | |
10 | (driver: glr) | |
11 | (A) | |
12 | (e (A) : (list $1) | |
13 | (A A) : (list $1 $2) | |
14 | (A A A) : (list $1 $2 $3) | |
15 | () : 0)))) | |
16 | (parser (make-lexer tokens) error-handler))) | |
17 | ||
18 | (check | |
19 | (doit (make-lexical-token 'A #f 1)) | |
20 | => '((1))) | |
21 | ||
22 | (check | |
23 | (doit (make-lexical-token 'A #f 1) | |
24 | (make-lexical-token 'A #f 2)) | |
25 | => '((1 2))) | |
26 | ||
27 | (check | |
28 | (doit (make-lexical-token 'A #f 1) | |
29 | (make-lexical-token 'A #f 2) | |
30 | (make-lexical-token 'A #f 3)) | |
31 | => '((1 2 3))) | |
32 | ||
33 | (check | |
34 | (doit) | |
35 | => '(0)) | |
36 | ||
37 | ;;; end of file |