test-lr-basics-04.scm 592 B

1234567891011121314151617181920212223242526272829303132
  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. (load "common-test.scm")
  6. (define (doit . tokens)
  7. (let ((parser (lalr-parser (expect: 0)
  8. (A)
  9. (e (e A) : $2
  10. (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. => 3)
  24. ;;; end of file