test-glr-basics-02.scm 533 B

12345678910111213141516171819202122232425262728293031
  1. ;;; test-lr-basics-02.scm --
  2. ;;
  3. ;;A grammar that only accept a single terminal or the EOI.
  4. ;;
  5. (load "common-test.scm")
  6. (define (doit . tokens)
  7. (let ((parser (lalr-parser (expect: 0)
  8. (driver: glr)
  9. (A)
  10. (e (A) : $1
  11. () : 0))))
  12. (parser (make-lexer tokens) error-handler)))
  13. (check
  14. (doit)
  15. => '(0))
  16. (check
  17. (doit (make-lexical-token 'A #f 1))
  18. => '(1))
  19. (check
  20. (doit (make-lexical-token 'A #f 1)
  21. (make-lexical-token 'A #f 2)
  22. (make-lexical-token 'A #f 3))
  23. => '())
  24. ;;; end of file