| 1 | ;;; test-lr-basics-04.scm -- |
| 2 | ;; |
| 3 | ;;A grammar accepting a sequence of equal tokens of arbitrary length. |
| 4 | ;;The return value is the value of the last parsed token. |
| 5 | |
| 6 | |
| 7 | (load "common-test.scm") |
| 8 | |
| 9 | (define (doit . tokens) |
| 10 | (let ((parser (lalr-parser (expect: 0) |
| 11 | (A) |
| 12 | (e (e A) : $2 |
| 13 | (A) : $1 |
| 14 | () : 0)))) |
| 15 | (parser (make-lexer tokens) error-handler))) |
| 16 | |
| 17 | (check |
| 18 | (doit) |
| 19 | => 0) |
| 20 | |
| 21 | (check |
| 22 | (doit (make-lexical-token 'A #f 1)) |
| 23 | => 1) |
| 24 | |
| 25 | (check |
| 26 | (doit (make-lexical-token 'A #f 1) |
| 27 | (make-lexical-token 'A #f 2) |
| 28 | (make-lexical-token 'A #f 3)) |
| 29 | => 3) |
| 30 | |
| 31 | ;;; end of file |