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