lalr.scm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ;;; -*- mode: scheme; coding: utf-8; -*-
  2. ;;;
  3. ;;; Copyright (C) 2010 Free Software Foundation, Inc.
  4. ;;;
  5. ;;; This library is free software; you can redistribute it and/or modify it
  6. ;;; under the terms of the GNU Lesser General Public License as published by
  7. ;;; the Free Software Foundation; either version 3 of the License, or (at
  8. ;;; your option) any later version.
  9. ;;;
  10. ;;; This library is distributed in the hope that it will be useful, but
  11. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  13. ;;; General Public License for more details.
  14. ;;;
  15. ;;; You should have received a copy of the GNU Lesser General Public License
  16. ;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. (define-module (system base lalr)
  18. ;; XXX: In theory this import is not needed but the evaluator (not the
  19. ;; compiler) complains about `lexical-token' being unbound when expanding
  20. ;; `(define-record-type lexical-token ...)' if we omit it.
  21. #:use-module (srfi srfi-9)
  22. #:export (lalr-parser print-states
  23. make-lexical-token lexical-token?
  24. lexical-token-category
  25. lexical-token-source
  26. lexical-token-value
  27. make-source-location source-location?
  28. source-location-input
  29. source-location-line
  30. source-location-column
  31. source-location-offset
  32. source-location-length
  33. source-location->source-properties
  34. ;; `lalr-parser' is a defmacro, which produces code that refers to
  35. ;; these drivers.
  36. lr-driver glr-driver))
  37. ;; The LALR parser generator was written by Dominique Boucher. It's available
  38. ;; from http://code.google.com/p/lalr-scm/ and released under the LGPLv3+.
  39. (include-from-path "system/base/lalr.upstream.scm")
  40. (define (source-location->source-properties loc)
  41. `((filename . ,(source-location-input loc))
  42. (line . ,(source-location-line loc))
  43. (column . ,(source-location-column loc))))