Merge branch 'master' into wip-manual-2
[bpt/guile.git] / test-suite / lalr / test-glr-basics-04.scm
CommitLineData
1b101522
LC
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 (driver: glr)
12 (A)
13 (e (e A) : $2
14 (A) : $1
15 () : 0))))
16 (parser (make-lexer tokens) error-handler)))
17
18(check
19 (doit)
20 => '(0))
21
22(check
23 ;;Two results because there is a shift/reduce conflict, so two
24 ;;processes are generated.
25 (doit (make-lexical-token 'A #f 1))
26 => '(1 1))
27
28(check
29 ;;Two results because there is a shift/reduce conflict, so two
30 ;;processes are generated. Notice that the rules:
31 ;;
32 ;; (e A) (A)
33 ;;
34 ;;generate only one conflict when the second "A" comes. The third
35 ;;"A" comes when the state is inside the rule "(e A)", so there is
36 ;;no conflict.
37 ;;
38 (doit (make-lexical-token 'A #f 1)
39 (make-lexical-token 'A #f 2)
40 (make-lexical-token 'A #f 3))
41 => '(3 3))
42
43;;; end of file