1 ;;; -*- mode: scheme; coding: utf-8; -*-
3 ;;; Copyright (C) 2010 Free Software Foundation, Inc.
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.
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.
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/>.
18 (define-module (system base lalr)
20 ;; XXX: In theory this import is not needed but the evaluator (not the
21 ;; compiler) complains about `lexical-token' being unbound when expanding
22 ;; `(define-record-type lexical-token ...)' if we omit it.
23 #:use-module (srfi srfi-9)
25 #:export (lalr-parser print-states
27 make-lexical-token lexical-token?
28 lexical-token-category
32 make-source-location source-location?
35 source-location-column
36 source-location-offset
37 source-location-length
38 source-location->source-properties
40 ;; `lalr-parser' is a defmacro, which produces code that refers to
42 lr-driver glr-driver))
44 ;; The LALR parser generator was written by Dominique Boucher. It's available
45 ;; from http://code.google.com/p/lalr-scm/ and released under the LGPLv3+.
46 (include-from-path "system/base/lalr.upstream.scm")
48 (define (source-location->source-properties loc)
49 `((filename . ,(source-location-input loc))
50 (line . ,(source-location-line loc))
51 (column . ,(source-location-column loc))))