1 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; -*-
3 ;;; entrypoints.lisp --- parser generator entry points
5 ;; Copyright (C) 2008 Utz-Uwe Haus <lisp@uuhaus.de>
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
27 ;; This file contains code for the opossum package that depends on
28 ;; the parser part already being compiled to avoid undefined symbol warnings
34 (in-package #:opossum
)
37 (defmacro get-string-parser
(pkg)
38 "Return the parse-string function in the package PKG."
39 `(let ((*package
* ,pkg
))
42 (defmacro get-file-parser
(pkg)
43 "Return the parse-file function in the package PKG."
44 `(let ((*package
* ,pkg
))
47 (defmacro get-stream-parser
(pkg)
48 "Return the parse-stream function in the package PKG."
49 `(let ((*package
* ,pkg
))
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
))
59 (apply #'opossum
:generate-parser-package grammarfile args
)))
61 (defun make-file-parser (grammarfile head
&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 dst-package head
)))
65 (defun make-stream-parser (grammarfile head
&key
(dst-package (make-default-dst-package grammarfile
)))
66 "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."
67 (get-stream-parser (opossum:generate-parser-package grammarfile dst-package head
)))