Code cleanup againt SBCL, CMUCL and ECL.
[cl-opossum.git] / entrypoints.lisp
blob4aae43ceafd35d295e9e1a20f57866e5aa4250cc
1 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; -*-
2 ;;;
3 ;;; entrypoints.lisp --- parser generator entry points
5 ;; Copyright (C) 2008 Utz-Uwe Haus <lisp@uuhaus.de>
6 ;; $Id$
7 ;;
8 ;; This code is free software; you can redistribute it and/or modify
9 ;; it under the terms of the version 2.1 of the GNU Lesser General
10 ;; Public License as published by the Free Software Foundation, as
11 ;; clarified by the lisp prequel found in LICENSE.
13 ;; This code is distributed in the hope that it will be useful, but
14 ;; without any warranty; without even the implied warranty of
15 ;; merchantability or fitness for a particular purpose. See the GNU
16 ;; Lesser General Public License for more details.
18 ;; Version 2.1 of the GNU General Public License is in the file
19 ;; LICENSE that was distributed with this file. If it is not
20 ;; present, you can access it from
21 ;; http://www.gnu.org/copyleft/lgpl.txt (until superseded by a
22 ;; newer version) or write to the Free Software Foundation, Inc., 59
23 ;; Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 ;; Commentary:
27 ;; This file contains code for the opossum package that depends on
28 ;; the parser part already being compiled to avoid undefined symbol warnings
30 ;;; Code:
34 (in-package #:opossum)
36 ;; low-level macros
37 (defmacro get-string-parser (pkg)
38 "Return the parse-string function in the package PKG."
39 `(let ((*package* ,pkg))
40 #'parse-string))
42 (defmacro get-file-parser (pkg)
43 "Return the parse-file function in the package PKG."
44 `(let ((*package* ,pkg))
45 #'parse-file))
47 (defmacro get-stream-parser (pkg)
48 "Return the parse-stream function in the package PKG."
49 `(let ((*package* ,pkg))
50 #'parse-stream))
53 ;;; parser entry point
54 (defun make-string-parser (grammarfile &rest args
55 &key start-rule dst-package )
56 "Return a function of 1 argument, a string, that parses according to GRAMMARFILE, starting at rule named HEAD. The parser is instantiated in package DST-PACKAGE."
57 (declare (ignore start-rule dst-package))
58 (get-string-parser
59 (apply #'opossum:generate-parser-package grammarfile args)))
61 (defun make-file-parser (grammarfile start-rule &key (dst-package (make-default-dst-package grammarfile)))
62 "Return a function of 1 argument, a file, that parses according to GRAMMARFILE, starting at rule named HEAD. The parser is instantiated in package DST-PACKAGE."
63 (get-file-parser (opossum:generate-parser-package grammarfile
64 :dst-package dst-package
65 :start-rule start-rule)))
67 (defun make-stream-parser (grammarfile start-rule &key (dst-package (make-default-dst-package grammarfile)))
68 "Return a function of 1 argument, a stream, that parses according to GRAMMARFILE, starting at rule named HEAD. The parser is instantiated in package DST-PACKAGE."
69 (get-stream-parser (opossum:generate-parser-package grammarfile
70 :dst-package dst-package
71 :start-rule start-rule)))