mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
Taken from r51 of <http://lalr-scm.googlecode.com/svn/trunk>. * module/Makefile.am (SYSTEM_BASE_SOURCES): Add `system/base/lalr.scm'. (NOCOMP_SOURCES): Add `system/base/lalr.upstream.scm'. * module/system/base/lalr.scm, module/system/base/lalr.upstream.scm: New files. * test-suite/Makefile.am (LALR_TESTS, LALR_EXTRA, TESTS, TESTS_ENVIRONMENT): New variables. (EXTRA_DIST): Add $(LALR_EXTRA). * test-suite/lalr/common-test.scm, test-suite/lalr/glr-test.scm, test-suite/lalr/test-glr-associativity.scm, test-suite/lalr/test-glr-basics-01.scm, test-suite/lalr/test-glr-basics-02.scm, test-suite/lalr/test-glr-basics-03.scm, test-suite/lalr/test-glr-basics-04.scm, test-suite/lalr/test-glr-basics-05.scm, test-suite/lalr/test-glr-script-expression.scm, test-suite/lalr/test-glr-single-expressions.scm, test-suite/lalr/test-lr-associativity-01.scm, test-suite/lalr/test-lr-associativity-02.scm, test-suite/lalr/test-lr-associativity-03.scm, test-suite/lalr/test-lr-associativity-04.scm, test-suite/lalr/test-lr-basics-01.scm, test-suite/lalr/test-lr-basics-02.scm, test-suite/lalr/test-lr-basics-03.scm, test-suite/lalr/test-lr-basics-04.scm, test-suite/lalr/test-lr-basics-05.scm, test-suite/lalr/test-lr-error-recovery-01.scm, test-suite/lalr/test-lr-error-recovery-02.scm, test-suite/lalr/test-lr-no-clause.scm, test-suite/lalr/test-lr-script-expression.scm, test-suite/lalr/test-lr-single-expressions.scm: New files.
40 lines
1.1 KiB
Scheme
40 lines
1.1 KiB
Scheme
;;; 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
|