blob: fb98da6d8c404a3a8f51c2180bb097fc7b857019 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
;;; test-lr-no-clause.scm --
;;
(load "common-test.scm")
(define (doit . tokens)
(let ((parser (lalr-parser (expect: 0)
(NUMBER COMMA NEWLINE)
(lines (lines line) : (list $2)
(line) : (list $1))
(line (NEWLINE) : #\newline
(NUMBER NEWLINE) : $1
;;this is a rule with no semantic action
(COMMA NUMBER NEWLINE)))))
(parser (make-lexer tokens) error-handler)))
(check
;;correct input
(doit (make-lexical-token 'NUMBER #f 1)
(make-lexical-token 'NEWLINE #f #\newline))
=> '(1))
(check
;;correct input with comma, which is a rule with no client form
(doit (make-lexical-token 'COMMA #f #\,)
(make-lexical-token 'NUMBER #f 1)
(make-lexical-token 'NEWLINE #f #\newline))
=> '(#(line-3 #\, 1 #\newline)))
(check
;;correct input with comma, which is a rule with no client form
(doit (make-lexical-token 'NUMBER #f 1)
(make-lexical-token 'NEWLINE #f #\newline)
(make-lexical-token 'COMMA #f #\,)
(make-lexical-token 'NUMBER #f 2)
(make-lexical-token 'NEWLINE #f #\newline))
=> '(#(line-3 #\, 2 #\newline)))
;;; end of file
|