Commit | Line | Data |
---|---|---|
1b101522 LC |
1 | ;;; test-lr-basics-05.scm -- |
2 | ;; | |
3 | ;;A grammar accepting a sequence of equal tokens of arbitrary length. | |
4 | ;;The return value is the list of values. | |
5 | ;; | |
6 | ||
7 | (load "common-test.scm") | |
8 | ||
9 | (define (doit . tokens) | |
10 | (let ((parser (lalr-parser (expect: 0) | |
11 | (driver: glr) | |
12 | (A) | |
13 | (e (e A) : (cons $2 $1) | |
14 | (A) : (list $1) | |
15 | () : (list 0))))) | |
16 | (parser (make-lexer tokens) error-handler))) | |
17 | ||
18 | (check | |
19 | (doit) | |
20 | => '((0))) | |
21 | ||
22 | (check | |
23 | (doit (make-lexical-token 'A #f 1)) | |
24 | => '((1 0) | |
25 | (1))) | |
26 | ||
27 | (check | |
28 | (doit (make-lexical-token 'A #f 1) | |
29 | (make-lexical-token 'A #f 2)) | |
30 | => '((2 1 0) | |
31 | (2 1))) | |
32 | ||
33 | (check | |
34 | (doit (make-lexical-token 'A #f 1) | |
35 | (make-lexical-token 'A #f 2) | |
36 | (make-lexical-token 'A #f 3)) | |
37 | => '((3 2 1 0) | |
38 | (3 2 1))) | |
39 | ||
40 | ;;; end of file |