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 18(define-module (system base lalr) 19 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) 24 25 #:export (lalr-parser print-states 26 27 make-lexical-token lexical-token? 28 lexical-token-category 29 lexical-token-source 30 lexical-token-value 31 32 make-source-location source-location? 33 source-location-input 34 source-location-line 35 source-location-column 36 source-location-offset 37 source-location-length 38 source-location->source-properties 39 40 ;; `lalr-parser' is a defmacro, which produces code that refers to 41 ;; these drivers. 42 lr-driver glr-driver)) 43 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") 47 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)))) 52