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 | (A) | |
11 | (e (A) : (list $1) | |
12 | (A A) : (list $1 $2) | |
13 | (A A A) : (list $1 $2 $3) | |
14 | () : 0)))) | |
15 | (parser (make-lexer tokens) error-handler))) | |
16 | ||
17 | (check | |
18 | (doit (make-lexical-token 'A #f 1)) | |
19 | => '(1)) | |
20 | ||
21 | (check | |
22 | (doit (make-lexical-token 'A #f 1) | |
23 | (make-lexical-token 'A #f 2)) | |
24 | => '(1 2)) | |
25 | ||
26 | (check | |
27 | (doit (make-lexical-token 'A #f 1) | |
28 | (make-lexical-token 'A #f 2) | |
29 | (make-lexical-token 'A #f 3)) | |
30 | => '(1 2 3)) | |
31 | ||
32 | (check | |
33 | (doit) | |
34 | => 0) | |
35 | ||
36 | ;;; end of file |