Initial revision
This commit is contained in:
521
glisp/COPYING
Normal file
521
glisp/COPYING
Normal file
@ -0,0 +1,521 @@
|
||||
Preamble to the Gnu Lesser General Public License
|
||||
|
||||
Copyright (c) 2000 Franz Incorporated, Berkeley, CA 94704
|
||||
|
||||
The concept of the GNU Lesser General Public License version 2.1
|
||||
("LGPL") has been adopted to govern the use and distribution of
|
||||
above-mentioned application. However, the LGPL uses terminology that is
|
||||
more appropriate for a program written in C than one written in
|
||||
Lisp. Nevertheless, the LGPL can still be applied to a Lisp program if
|
||||
certain clarifications are made. This document details those
|
||||
clarifications. Accordingly, the license for the open-source Lisp
|
||||
applications consists of this document plus the LGPL. Wherever there is
|
||||
a conflict between this document and the LGPL, this document takes
|
||||
precedence over the LGPL.
|
||||
|
||||
A "Library" in Lisp is a collection of Lisp functions, data and foreign
|
||||
modules. The form of the Library can be Lisp source code (for processing
|
||||
by an interpreter) or object code (usually the result of compilation of
|
||||
source code or built with some other mechanisms). Foreign modules are
|
||||
object code in a form that can be linked into a Lisp executable. When we
|
||||
speak of functions we do so in the most general way to include, in
|
||||
addition, methods and unnamed functions. Lisp "data" is also a general
|
||||
term that includes the data structures resulting from defining Lisp
|
||||
classes. A Lisp application may include the same set of Lisp objects as
|
||||
does a Library, but this does not mean that the application is
|
||||
necessarily a "work based on the Library" it contains.
|
||||
|
||||
The Library consists of everything in the distribution file set before
|
||||
any modifications are made to the files. If any of the functions or
|
||||
classes in the Library are redefined in other files, then those
|
||||
redefinitions ARE considered a work based on the Library. If additional
|
||||
methods are added to generic functions in the Library, those additional
|
||||
methods are NOT considered a work based on the Library. If Library
|
||||
classes are subclassed, these subclasses are NOT considered a work based
|
||||
on the Library. If the Library is modified to explicitly call other
|
||||
functions that are neither part of Lisp itself nor an available add-on
|
||||
module to Lisp, then the functions called by the modified Library ARE
|
||||
considered a work based on the Library. The goal is to ensure that the
|
||||
Library will compile and run without getting undefined function errors.
|
||||
|
||||
It is permitted to add proprietary source code to the Library, but it
|
||||
must be done in a way such that the Library will still run without that
|
||||
proprietary code present. Section 5 of the LGPL distinguishes between
|
||||
the case of a library being dynamically linked at runtime and one being
|
||||
statically linked at build time. Section 5 of the LGPL states that the
|
||||
former results in an executable that is a "work that uses the Library."
|
||||
Section 5 of the LGPL states that the latter results in one that is a
|
||||
"derivative of the Library", which is therefore covered by the
|
||||
LGPL. Since Lisp only offers one choice, which is to link the Library
|
||||
into an executable at build time, we declare that, for the purpose
|
||||
applying the LGPL to the Library, an executable that results from
|
||||
linking a "work that uses the Library" with the Library is considered a
|
||||
"work that uses the Library" and is therefore NOT covered by the LGPL.
|
||||
|
||||
Because of this declaration, section 6 of LGPL is not applicable to the
|
||||
Library. However, in connection with each distribution of this
|
||||
executable, you must also deliver, in accordance with the terms and
|
||||
conditions of the LGPL, the source code of Library (or your derivative
|
||||
thereof) that is incorporated into this executable.
|
||||
|
||||
End of Document
|
||||
------------------------------------------------------------------------
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
132
glisp/characters.lisp
Normal file
132
glisp/characters.lisp
Normal file
@ -0,0 +1,132 @@
|
||||
;;; copyright (c) 2004 knowledgeTools Int. GmbH
|
||||
;;; Author of this version: David Lichteblau <david@knowledgetools.de>
|
||||
;;;
|
||||
;;; License: LGPL (See file COPYING for details).
|
||||
;;;
|
||||
;;; derived from runes.lisp, (c) copyright 1998,1999 by Gilbert Baumann
|
||||
|
||||
(in-package :glisp)
|
||||
|
||||
(deftype rune () 'base-char)
|
||||
(deftype rod () 'base-string)
|
||||
(deftype simple-rod () 'simple-string)
|
||||
|
||||
(defsubst rune (rod index)
|
||||
(char rod index))
|
||||
|
||||
(defun (setf rune) (new rod index)
|
||||
(setf (char rod index) new))
|
||||
|
||||
(defsubst %rune (rod index)
|
||||
(aref (the simple-string rod) (the fixnum index)))
|
||||
|
||||
(defsubst (setf %rune) (new rod index)
|
||||
(setf (aref (the simple-string rod) (the fixnum index)) new))
|
||||
|
||||
(defun rod-capitalize (rod)
|
||||
(string-upcase rod))
|
||||
|
||||
(defsubst code-rune (x) (code-char x))
|
||||
(defsubst rune-code (x) (char-code x))
|
||||
|
||||
(defsubst rune= (x y)
|
||||
(char= x y))
|
||||
|
||||
(defun rune-downcase (rune)
|
||||
(char-downcase rune))
|
||||
|
||||
(defsubst rune-upcase (rune)
|
||||
(char-upcase rune))
|
||||
|
||||
(defun rune-upper-case-letter-p (rune)
|
||||
(upper-case-p rune))
|
||||
|
||||
(defun rune-lower-case-letter-p (rune)
|
||||
(lower-case-p rune))
|
||||
|
||||
(defun rune-equal (x y)
|
||||
(char-equal x y))
|
||||
|
||||
(defun rod-downcase (rod)
|
||||
(string-downcase rod))
|
||||
|
||||
(defun rod-upcase (rod)
|
||||
(string-upcase rod))
|
||||
|
||||
(defsubst white-space-rune-p (char)
|
||||
(or (char= char #\tab)
|
||||
(char= char #.(code-char 10)) ;Linefeed
|
||||
(char= char #.(code-char 13)) ;Carriage Return
|
||||
(char= char #\space)))
|
||||
|
||||
(defsubst digit-rune-p (char &optional (radix 10))
|
||||
(digit-char-p char radix))
|
||||
|
||||
(defun rod (x)
|
||||
(cond
|
||||
((stringp x) x)
|
||||
((symbolp x) (string x))
|
||||
((characterp x) (string x))
|
||||
((vectorp x) (coerce x 'string))
|
||||
((integerp x) (string (code-char x)))
|
||||
(t (error "Cannot convert ~S to a ~S" x 'rod))))
|
||||
|
||||
(defun runep (x)
|
||||
(characterp x))
|
||||
|
||||
(defun sloopy-rod-p (x)
|
||||
(stringp x))
|
||||
|
||||
(defun rod= (x y)
|
||||
(string= x y))
|
||||
|
||||
(defun rod-equal (x y)
|
||||
(string-equal x y))
|
||||
|
||||
(defsubst make-rod (size)
|
||||
(make-string size))
|
||||
|
||||
(defun char-rune (char)
|
||||
char)
|
||||
|
||||
(defun rune-char (rune &optional default)
|
||||
(declare (ignore default))
|
||||
rune)
|
||||
|
||||
(defun rod-string (rod &optional (default-char #\?))
|
||||
(declare (ignore default-char))
|
||||
rod)
|
||||
|
||||
(defun string-rod (string)
|
||||
string)
|
||||
|
||||
;;;;
|
||||
|
||||
(defun rune<= (rune &rest more-runes)
|
||||
(loop
|
||||
for (a b) on (cons rune more-runes)
|
||||
while b
|
||||
always (char<= a b)))
|
||||
|
||||
(defun rune>= (rune &rest more-runes)
|
||||
(loop
|
||||
for (a b) on (cons rune more-runes)
|
||||
while b
|
||||
always (char>= a b)))
|
||||
|
||||
(defun rodp (object)
|
||||
(stringp object))
|
||||
|
||||
(defun really-rod-p (object)
|
||||
(stringp object))
|
||||
|
||||
(defun rod-subseq (source start &optional (end (length source)))
|
||||
(unless (stringp source)
|
||||
(error "~S is not of type ~S." source 'rod))
|
||||
(subseq source start end))
|
||||
|
||||
(defun rod-subseq* (source start &optional (end (length source)))
|
||||
(rod-subseq source start end))
|
||||
|
||||
(defun rod< (rod1 rod2)
|
||||
(string< rod1 rod2))
|
||||
127
glisp/dep-acl.lisp
Normal file
127
glisp/dep-acl.lisp
Normal file
@ -0,0 +1,127 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: GLISP; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: ACL-4.3 dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:33
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1998,1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(export 'glisp::read-byte-sequence :glisp)
|
||||
(export 'glisp::read-char-sequence :glisp)
|
||||
(export 'glisp::run-unix-shell-command :glisp)
|
||||
(export 'glisp::mp/process-run-function :glisp)
|
||||
(export 'glisp::mp/process-kill :glisp)
|
||||
(export 'glisp::mp/seize-lock :glisp)
|
||||
(export 'glisp::mp/release-lock :glisp)
|
||||
(export 'glisp::mp/transfer-lock-owner :glisp)
|
||||
(export 'glisp::mp/current-process :glisp)
|
||||
(export 'glisp::mp/process-yield :glisp)
|
||||
(export 'glisp::mp/process-wait :glisp)
|
||||
(export 'glisp::getenv :glisp)
|
||||
|
||||
(defun glisp::read-byte-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-char-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
#+ALLEGRO-V5.0
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(values
|
||||
(socket:make-socket :remote-host hostname
|
||||
:remote-port port
|
||||
:format :binary)
|
||||
:byte))
|
||||
|
||||
#-ALLEGRO-V5.0
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(values
|
||||
(ipc:open-network-stream :host hostname
|
||||
:port port
|
||||
:element-type '(unsigned-byte 8)
|
||||
:class 'EXCL::BIDIRECTIONAL-BINARY-SOCKET-STREAM)
|
||||
:byte))
|
||||
|
||||
#||
|
||||
(defun glisp::make-server-socket (port &key (element-type '(unsigned-byte 8)))
|
||||
)
|
||||
||#
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
(mp:make-process-lock :name name))
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
`(mp:with-process-lock (,lock)
|
||||
,@body))
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest options) &body body)
|
||||
`(mp:with-timeout ,options . ,body))
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length :element-type 'base-char options))
|
||||
|
||||
(defun glisp:run-unix-shell-command (cmd)
|
||||
(excl:shell cmd))
|
||||
|
||||
(defun glisp:mp/process-run-function (name fn &rest args)
|
||||
(apply #'mp:process-run-function name fn args))
|
||||
|
||||
(defun glisp:mp/process-kill (proc)
|
||||
(mp:process-kill proc))
|
||||
|
||||
(defun glisp:mp/current-process ()
|
||||
sys:*current-process*)
|
||||
|
||||
(defun glisp::mp/seize-lock (lock &key whostate)
|
||||
whostate
|
||||
(mp:process-lock lock))
|
||||
|
||||
(defun glisp::mp/transfer-lock-owner (lock old-process new-process)
|
||||
(assert (eql (mp:process-lock-locker lock) old-process))
|
||||
(setf (mp:process-lock-locker lock) new-process)
|
||||
)
|
||||
|
||||
(defun glisp::mp/release-lock (lock)
|
||||
(mp:process-unlock lock))
|
||||
|
||||
(defun glisp::mp/process-yield (&optional process-to-run)
|
||||
(mp:process-allow-schedule process-to-run))
|
||||
|
||||
(defun glisp::mp/process-wait (whostate predicate)
|
||||
(mp:process-wait whostate predicate))
|
||||
|
||||
;; ACL is incapable to define compiler macros on (setf foo)
|
||||
;; Unfortunately it is also incapable to declaim such functions inline.
|
||||
;; So we revoke the DEFUN hack from dep-gcl here.
|
||||
|
||||
(defmacro glisp::defsubst (fun args &body body)
|
||||
(if (and (consp fun) (eq (car fun) 'setf))
|
||||
(let ((fnam (intern (concatenate 'string "(SETF " (symbol-name (cadr fun)) ")")
|
||||
(symbol-package (cadr fun)))))
|
||||
`(progn
|
||||
(defsetf ,(cadr fun) (&rest ap) (new-value) (list* ',fnam new-value ap))
|
||||
(glisp::defsubst ,fnam ,args .,body)))
|
||||
`(progn
|
||||
(defun ,fun ,args .,body)
|
||||
(define-compiler-macro ,fun (&rest .args.)
|
||||
(cons '(lambda ,args .,body)
|
||||
.args.)))))
|
||||
|
||||
|
||||
(defun glisp::getenv (string)
|
||||
(sys:getenv string))
|
||||
162
glisp/dep-acl5.lisp
Normal file
162
glisp/dep-acl5.lisp
Normal file
@ -0,0 +1,162 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; Encoding: utf-8; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: ACL-5.0 dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:32
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1998,1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Changes
|
||||
;;; =======
|
||||
|
||||
;;; When Who What
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; 2002-01-04 GB spend BLOCK for DEFSUBST
|
||||
;;; 1999-08-31 SES Stig Erik Sandø <stig@ii.uib.no>
|
||||
;;;
|
||||
;;; Changed #+allegro-v5.0 to
|
||||
;;; #+(and allegro-version>= (version>= 5))
|
||||
;;;
|
||||
|
||||
(export 'glisp::read-byte-sequence :glisp)
|
||||
(export 'glisp::read-char-sequence :glisp)
|
||||
(export 'glisp::run-unix-shell-command :glisp)
|
||||
(export 'glisp::mp/process-run-function :glisp)
|
||||
(export 'glisp::mp/process-kill :glisp)
|
||||
(export 'glisp::mp/current-process :glisp)
|
||||
(export 'glisp::mp/seize-lock :glisp)
|
||||
(export 'glisp::mp/release-lock :glisp)
|
||||
(export 'glisp::mp/process-yield :glisp)
|
||||
(export 'glisp::mp/process-wait :glisp)
|
||||
(export 'glisp::getenv :glisp)
|
||||
|
||||
(export 'glisp::make-server-socket :glisp)
|
||||
|
||||
(defun glisp::mp/seize-lock (lock &key whostate)
|
||||
whostate
|
||||
(mp:process-lock lock))
|
||||
|
||||
(defun glisp::mp/release-lock (lock)
|
||||
(mp:process-unlock lock))
|
||||
|
||||
(defun glisp::read-byte-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-char-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
#+(and allegro-version>= (version>= 5))
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(values
|
||||
(socket:make-socket :remote-host hostname
|
||||
:remote-port port
|
||||
:format :binary)
|
||||
:byte))
|
||||
|
||||
(defun glisp::make-server-socket (port &key (element-type '(unsigned-byte 8)))
|
||||
(socket:make-socket :connect :passive
|
||||
:local-port port
|
||||
:format (cond ((subtypep element-type '(unsigned-byte 8))
|
||||
:binary)
|
||||
((subtypep element-type 'character)
|
||||
:text)
|
||||
(t
|
||||
(error "Unknown element type: ~S." element-type)))))
|
||||
|
||||
(defun glisp::accept-connection/low (socket)
|
||||
(values
|
||||
(socket:accept-connection socket :wait t)
|
||||
:byte))
|
||||
|
||||
|
||||
#-(and allegro-version>= (version>= 5))
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(values
|
||||
(ipc:open-network-stream :host hostname
|
||||
:port port
|
||||
:element-type '(unsigned-byte 8)
|
||||
:class 'EXCL::BIDIRECTIONAL-BINARY-SOCKET-STREAM)
|
||||
:byte))
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
(mp:make-process-lock :name name))
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
`(mp:with-process-lock (,lock)
|
||||
,@body))
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest options) &body body)
|
||||
`(mp:with-timeout ,options . ,body))
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length :element-type 'base-char options))
|
||||
|
||||
(defun glisp:run-unix-shell-command (cmd)
|
||||
(excl:shell cmd))
|
||||
|
||||
(defparameter glisp::*inherited-vars*
|
||||
'(*terminal-io* *standard-input* *standard-output* *error-output* *trace-output* *query-io* *debug-io*))
|
||||
|
||||
(defparameter glisp::*inherited-vars* nil)
|
||||
|
||||
(defun glisp:mp/process-run-function (name fn &rest args)
|
||||
(mp:process-run-function
|
||||
name
|
||||
(lambda (vars vals fn args)
|
||||
(progv vars vals
|
||||
(apply fn args)))
|
||||
glisp::*inherited-vars* (mapcar #'symbol-value glisp::*inherited-vars*)
|
||||
fn args))
|
||||
|
||||
(defun glisp:mp/current-process ()
|
||||
sys:*current-process*)
|
||||
|
||||
(defun glisp::mp/process-yield (&optional process-to-run)
|
||||
(mp:process-allow-schedule process-to-run))
|
||||
|
||||
(defun glisp::mp/process-wait (whostate predicate)
|
||||
(mp:process-wait whostate predicate))
|
||||
|
||||
(defun glisp::mp/process-kill (proc)
|
||||
(mp:process-kill proc))
|
||||
|
||||
;; ACL is incapable to define compiler macros on (setf foo)
|
||||
;; Unfortunately it is also incapable to declaim such functions inline.
|
||||
;; So we revoke the DEFUN hack from dep-gcl here.
|
||||
|
||||
(defmacro glisp::defsubst (fun args &body body)
|
||||
(if (and (consp fun) (eq (car fun) 'setf))
|
||||
(let ((fnam (intern (concatenate 'string "(SETF " (symbol-name (cadr fun)) ")")
|
||||
(symbol-package (cadr fun)))))
|
||||
`(progn
|
||||
(defsetf ,(cadr fun) (&rest ap) (new-value) (list* ',fnam new-value ap))
|
||||
(glisp::defsubst ,fnam ,args .,body)))
|
||||
(labels ((declp (x)
|
||||
(and (consp x) (eq (car x) 'declare))))
|
||||
`(progn
|
||||
(defun ,fun ,args .,body)
|
||||
(define-compiler-macro ,fun (&rest .args.)
|
||||
(cons '(lambda ,args
|
||||
,@(remove-if-not #'declp body)
|
||||
(block ,fun
|
||||
,@(remove-if #'declp body)))
|
||||
.args.))))))
|
||||
|
||||
|
||||
(defun glisp::getenv (string)
|
||||
(sys:getenv string))
|
||||
176
glisp/dep-clisp.lisp
Normal file
176
glisp/dep-clisp.lisp
Normal file
@ -0,0 +1,176 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: CLISP dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:32
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(in-package :CL-USER)
|
||||
|
||||
(eval-when (compile load eval)
|
||||
(if (fboundp 'cl::define-compiler-macro)
|
||||
(pushnew 'define-compiler-macro *features*)))
|
||||
|
||||
(setq lisp:*load-paths* '(#P"./"))
|
||||
|
||||
(import 'lisp:read-byte-sequence :glisp)
|
||||
(export 'lisp:read-byte-sequence :glisp)
|
||||
(import 'lisp:read-char-sequence :glisp)
|
||||
(export 'lisp:read-char-sequence :glisp)
|
||||
(export 'glisp::compile-file :glisp)
|
||||
(export 'glisp::run-unix-shell-command :glisp)
|
||||
(export 'glisp::make-server-socket :glisp)
|
||||
|
||||
|
||||
#||
|
||||
(export 'glisp::read-byte-sequence :glisp)
|
||||
(defun glisp::read-byte-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-byte input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
||#
|
||||
|
||||
|
||||
(defun glisp::compile-file (&rest ap)
|
||||
(and (apply #'compile-file ap)
|
||||
(apply #'compile-file-pathname ap)))
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest ignore) &body body)
|
||||
(declare (ignore ignore))
|
||||
`(progn
|
||||
,@body))
|
||||
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(values
|
||||
(lisp:socket-connect port hostname)
|
||||
:byte))
|
||||
|
||||
(defun glisp:make-server-socket (port)
|
||||
(lisp:socket-server port))
|
||||
|
||||
(defun glisp::accept-connection/low (socket)
|
||||
(let ((stream (lisp:socket-accept socket)))
|
||||
(setf (stream-element-type stream) '(unsigned-byte 8))
|
||||
(values
|
||||
stream
|
||||
:byte)))
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length
|
||||
:element-type
|
||||
'#.(cond ((stringp (make-array 1 :element-type 'string-char))
|
||||
'string-char)
|
||||
((stringp (make-array 1 :element-type 'base-char))
|
||||
'base-char)
|
||||
(t
|
||||
(error "What is the string element type of the day?")))
|
||||
options))
|
||||
|
||||
(defun glisp:run-unix-shell-command (command)
|
||||
(lisp:shell command))
|
||||
|
||||
#+DEFINE-COMPILER-MACRO
|
||||
(cl:define-compiler-macro ldb (bytespec value &whole whole)
|
||||
(let (pos size)
|
||||
(cond ((and (consp bytespec)
|
||||
(= (length bytespec) 3)
|
||||
(eq (car bytespec) 'byte)
|
||||
(constantp (setq size (second bytespec)))
|
||||
(constantp (setq pos (third bytespec))))
|
||||
`(logand ,(if (eql pos 0) value `(ash ,value (- ,pos)))
|
||||
(1- (ash 1 ,size))))
|
||||
(t
|
||||
whole))))
|
||||
|
||||
#-DEFINE-COMPILER-MACRO
|
||||
(progn
|
||||
(export 'glisp::define-compiler-macro :glisp)
|
||||
(defmacro glisp::define-compiler-macro (name args &body body)
|
||||
(declare (ignore args body))
|
||||
`(progn
|
||||
',name)))
|
||||
|
||||
#||
|
||||
(defun xlib:draw-glyph (drawable gcontext x y elt &rest more)
|
||||
(apply #'xlib:draw-glyphs drawable gcontext x y (vector elt) more))
|
||||
||#
|
||||
|
||||
(defmacro glisp::defsubst (name args &body body)
|
||||
`(progn
|
||||
(declaim (inline ,name))
|
||||
(defun ,name ,args .,body)))
|
||||
|
||||
(export 'glisp::getenv :glisp)
|
||||
(defun glisp::getenv (var)
|
||||
(sys::getenv var))
|
||||
|
||||
|
||||
|
||||
(export 'glisp::mp/process-run-function :glisp)
|
||||
(defun glisp:mp/process-run-function (name fn &rest args)
|
||||
(apply #'mp:process-run-function name fn args))
|
||||
|
||||
(export 'glisp::mp/process-kill :glisp)
|
||||
(defun glisp:mp/process-kill (proc)
|
||||
(mp:process-kill proc))
|
||||
|
||||
(export 'glisp::mp/current-process :glisp)
|
||||
(defun glisp:mp/current-process ()
|
||||
(mp:current-process))
|
||||
|
||||
(export 'glisp::mp/seize-lock :glisp)
|
||||
(defun glisp::mp/seize-lock (lock &key whostate)
|
||||
whostate
|
||||
(mp:process-lock lock))
|
||||
|
||||
(export 'glisp::mp/release-lock :glisp)
|
||||
(defun glisp::mp/release-lock (lock)
|
||||
(mp:process-unlock lock))
|
||||
|
||||
(export 'glisp::mp/process-yield :glisp)
|
||||
(defun glisp::mp/process-yield (&optional process-to-run)
|
||||
process-to-run
|
||||
(mp:process-allow-schedule))
|
||||
|
||||
(export 'glisp::mp/process-wait :glisp)
|
||||
(defun glisp::mp/process-wait (whostate predicate)
|
||||
(mp::process-wait whostate predicate))
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
`(mp:with-process-lock (,lock)
|
||||
,@body))
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
(mp:make-process-lock :name name))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
212
glisp/dep-cmucl-dtc.lisp
Normal file
212
glisp/dep-cmucl-dtc.lisp
Normal file
@ -0,0 +1,212 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: CMUCL dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:32
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(export 'glisp::read-byte-sequence :glisp)
|
||||
(export 'glisp::read-char-sequence :glisp)
|
||||
(export 'glisp::run-unix-shell-command :glisp)
|
||||
|
||||
(export 'glisp::getenv :glisp)
|
||||
|
||||
(defun glisp::read-byte-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-char-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-byte-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-byte input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
|
||||
(defun glisp::read-byte-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let ((r (read-sequence sequence input :start start :end end)))
|
||||
(cond ((and (= r start) (> end start))
|
||||
(let ((byte (read-byte input nil :eof)))
|
||||
(cond ((eq byte :eof)
|
||||
r)
|
||||
(t
|
||||
(setf (aref sequence start) byte)
|
||||
(incf start)
|
||||
(if (> end start)
|
||||
(glisp::read-byte-sequence sequence input :start start :end end)
|
||||
start)))))
|
||||
(t
|
||||
r))))
|
||||
|
||||
#||
|
||||
(defun glisp::read-char-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-byte input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
||#
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest ignore) &body body)
|
||||
(declare (ignore ignore))
|
||||
`(progn
|
||||
,@body))
|
||||
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(let ((fd (extensions:connect-to-inet-socket hostname port)))
|
||||
(values
|
||||
(sys:make-fd-stream fd
|
||||
:input t
|
||||
:output t
|
||||
:element-type '(unsigned-byte 8)
|
||||
:name (format nil "Network connection to ~A:~D" hostname port))
|
||||
:byte)))
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length :element-type 'base-char options))
|
||||
|
||||
#||
|
||||
|
||||
RUN-PROGRAM is an external symbol in the EXTENSIONS package.
|
||||
Function: #<Function RUN-PROGRAM {12E7B79}>
|
||||
Function arguments:
|
||||
(program args &key (env *environment-list*) (wait t) pty input
|
||||
if-input-does-not-exist output (if-output-exists :error) (error :output)
|
||||
(if-error-exists :error) status-hook)
|
||||
Function documentation:
|
||||
Run-program creates a new process and runs the unix progam in the
|
||||
file specified by the simple-string program. Args are the standard
|
||||
arguments that can be passed to a Unix program, for no arguments
|
||||
use NIL (which means just the name of the program is passed as arg 0).
|
||||
|
||||
Run program will either return NIL or a PROCESS structure. See the CMU
|
||||
Common Lisp Users Manual for details about the PROCESS structure.
|
||||
|
||||
The keyword arguments have the following meanings:
|
||||
:env -
|
||||
An A-LIST mapping keyword environment variables to simple-string
|
||||
values.
|
||||
:wait -
|
||||
If non-NIL (default), wait until the created process finishes. If
|
||||
NIL, continue running Lisp until the program finishes.
|
||||
:pty -
|
||||
Either T, NIL, or a stream. Unless NIL, the subprocess is established
|
||||
under a PTY. If :pty is a stream, all output to this pty is sent to
|
||||
this stream, otherwise the PROCESS-PTY slot is filled in with a stream
|
||||
connected to pty that can read output and write input.
|
||||
:input -
|
||||
Either T, NIL, a pathname, a stream, or :STREAM. If T, the standard
|
||||
input for the current process is inherited. If NIL, /dev/null
|
||||
is used. If a pathname, the file so specified is used. If a stream,
|
||||
all the input is read from that stream and send to the subprocess. If
|
||||
:STREAM, the PROCESS-INPUT slot is filled in with a stream that sends
|
||||
its output to the process. Defaults to NIL.
|
||||
:if-input-does-not-exist (when :input is the name of a file) -
|
||||
can be one of:
|
||||
:error - generate an error.
|
||||
:create - create an empty file.
|
||||
nil (default) - return nil from run-program.
|
||||
:output -
|
||||
Either T, NIL, a pathname, a stream, or :STREAM. If T, the standard
|
||||
output for the current process is inherited. If NIL, /dev/null
|
||||
is used. If a pathname, the file so specified is used. If a stream,
|
||||
all the output from the process is written to this stream. If
|
||||
:STREAM, the PROCESS-OUTPUT slot is filled in with a stream that can
|
||||
be read to get the output. Defaults to NIL.
|
||||
:if-output-exists (when :input is the name of a file) -
|
||||
can be one of:
|
||||
:error (default) - generates an error if the file already exists.
|
||||
:supersede - output from the program supersedes the file.
|
||||
:append - output from the program is appended to the file.
|
||||
nil - run-program returns nil without doing anything.
|
||||
:error and :if-error-exists -
|
||||
Same as :output and :if-output-exists, except that :error can also be
|
||||
specified as :output in which case all error output is routed to the
|
||||
same place as normal output.
|
||||
:status-hook -
|
||||
This is a function the system calls whenever the status of the
|
||||
process changes. The function takes the process as an argument.
|
||||
Its defined argument types are:
|
||||
(T T &KEY (:ENV T) (:WAIT T) (:PTY T) (:INPUT T) (:IF-INPUT-DOES-NOT-EXIST T)
|
||||
(:OUTPUT T) (:IF-OUTPUT-EXISTS T) (:ERROR T) (:IF-ERROR-EXISTS T)
|
||||
(:STATUS-HOOK T))
|
||||
Its result type is:
|
||||
(OR EXTENSIONS::PROCESS NULL)
|
||||
On Wednesday, 7/1/98 12:48:51 pm [-1] it was compiled from:
|
||||
target:code/run-program.lisp
|
||||
Created: Saturday, 6/20/98 07:13:08 pm [-1]
|
||||
Comment: $Header: /home/david/gitconversion/cvsroot/cxml/glisp/Attic/dep-cmucl-dtc.lisp,v 1.1 2005-03-13 18:02:10 david Exp $
|
||||
||#
|
||||
|
||||
;; (process-exit-code (run-program "/bin/sh" (list "-c" "ls") :wait t :input nil :output nil))
|
||||
|
||||
(defun glisp:run-unix-shell-command (command)
|
||||
(ext:process-exit-code (ext:run-program "/bin/sh" (list "-c" command) :wait t :input nil :output nil)))
|
||||
|
||||
(defmacro glisp::defsubst (name args &body body)
|
||||
`(progn
|
||||
(declaim (inline ,name))
|
||||
(defun ,name ,args .,body)))
|
||||
|
||||
|
||||
;;; MP
|
||||
|
||||
(export 'glisp::mp/process-yield :glisp)
|
||||
(export 'glisp::mp/process-wait :glisp)
|
||||
(export 'glisp::mp/process-run-function :glisp)
|
||||
(export 'glisp::mp/make-lock :glisp)
|
||||
(export 'glisp::mp/current-process :glisp)
|
||||
(export 'glisp::mp/process-kill :glisp)
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
(pthread::make-lock name))
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
`(pthread::with-lock-held (,lock)
|
||||
,@body))
|
||||
|
||||
(defun glisp::mp/process-yield (&optional process-to-run)
|
||||
(declare (ignore process-to-run))
|
||||
(PTHREAD:SCHED-YIELD))
|
||||
|
||||
(defun glisp::mp/process-wait (whostate predicate)
|
||||
(do ()
|
||||
((funcall predicate))
|
||||
(sleep .1)))
|
||||
|
||||
(defun glisp::mp/process-run-function (name fun &rest args)
|
||||
(pthread::thread-create
|
||||
(lambda ()
|
||||
(apply fun args))
|
||||
:name name))
|
||||
|
||||
(defun glisp::mp/current-process ()
|
||||
'blah)
|
||||
|
||||
(defun glisp::mp/process-kill (process)
|
||||
(warn "*** Define GLISP:MP/PROCESS-KILL for CMUCL."))
|
||||
|
||||
(defun glisp::getenv (string)
|
||||
(cdr (assoc string ext:*environment-list* :test #'string-equal)))
|
||||
|
||||
241
glisp/dep-cmucl.lisp
Normal file
241
glisp/dep-cmucl.lisp
Normal file
@ -0,0 +1,241 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: CMUCL dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:32
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(export 'glisp::read-byte-sequence :glisp)
|
||||
(export 'glisp::read-char-sequence :glisp)
|
||||
(export 'glisp::run-unix-shell-command :glisp)
|
||||
|
||||
(export 'glisp::getenv :glisp)
|
||||
|
||||
(export 'glisp::make-server-socket :glisp)
|
||||
(export 'glisp::close-server-socket :glisp)
|
||||
|
||||
(defun glisp::read-byte-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-char-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-byte-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-byte input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
|
||||
(defun glisp::read-byte-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let ((r (read-sequence sequence input :start start :end end)))
|
||||
(cond ((and (= r start) (> end start))
|
||||
(let ((byte (read-byte input nil :eof)))
|
||||
(cond ((eq byte :eof)
|
||||
r)
|
||||
(t
|
||||
(setf (aref sequence start) byte)
|
||||
(incf start)
|
||||
(if (> end start)
|
||||
(glisp::read-byte-sequence sequence input :start start :end end)
|
||||
start)))))
|
||||
(t
|
||||
r))))
|
||||
|
||||
#||
|
||||
(defun glisp::read-char-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-byte input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
||#
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest ignore) &body body)
|
||||
(declare (ignore ignore))
|
||||
`(progn
|
||||
,@body))
|
||||
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(let ((fd (extensions:connect-to-inet-socket hostname port)))
|
||||
(values
|
||||
(sys:make-fd-stream fd
|
||||
:input t
|
||||
:output t
|
||||
:element-type '(unsigned-byte 8)
|
||||
:name (format nil "Network connection to ~A:~D" hostname port))
|
||||
:byte)))
|
||||
|
||||
(defstruct (server-socket (:constructor make-server-socket-struct))
|
||||
fd
|
||||
element-type
|
||||
port)
|
||||
|
||||
(defun glisp::make-server-socket (port &key (element-type '(unsigned-byte 8)))
|
||||
(make-server-socket-struct :fd (ext:create-inet-listener port)
|
||||
:element-type element-type
|
||||
:port port))
|
||||
|
||||
(defun glisp::accept-connection/low (socket)
|
||||
(mp:process-wait-until-fd-usable (server-socket-fd socket) :input)
|
||||
(values
|
||||
(sys:make-fd-stream (ext:accept-tcp-connection (server-socket-fd socket))
|
||||
:input t :output t
|
||||
:element-type (server-socket-element-type socket))
|
||||
(cond ((subtypep (server-socket-element-type socket) 'integer)
|
||||
:byte)
|
||||
(t
|
||||
:char))))
|
||||
|
||||
(defun glisp::close-server-socket (socket)
|
||||
(unix:unix-close (server-socket-fd socket)))
|
||||
|
||||
;;;;;;
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length :element-type 'base-char options))
|
||||
|
||||
|
||||
|
||||
#||
|
||||
|
||||
RUN-PROGRAM is an external symbol in the EXTENSIONS package.
|
||||
Function: #<Function RUN-PROGRAM {12E7B79}>
|
||||
Function arguments:
|
||||
(program args &key (env *environment-list*) (wait t) pty input
|
||||
if-input-does-not-exist output (if-output-exists :error) (error :output)
|
||||
(if-error-exists :error) status-hook)
|
||||
Function documentation:
|
||||
Run-program creates a new process and runs the unix progam in the
|
||||
file specified by the simple-string program. Args are the standard
|
||||
arguments that can be passed to a Unix program, for no arguments
|
||||
use NIL (which means just the name of the program is passed as arg 0).
|
||||
|
||||
Run program will either return NIL or a PROCESS structure. See the CMU
|
||||
Common Lisp Users Manual for details about the PROCESS structure.
|
||||
|
||||
The keyword arguments have the following meanings:
|
||||
:env -
|
||||
An A-LIST mapping keyword environment variables to simple-string
|
||||
values.
|
||||
:wait -
|
||||
If non-NIL (default), wait until the created process finishes. If
|
||||
NIL, continue running Lisp until the program finishes.
|
||||
:pty -
|
||||
Either T, NIL, or a stream. Unless NIL, the subprocess is established
|
||||
under a PTY. If :pty is a stream, all output to this pty is sent to
|
||||
this stream, otherwise the PROCESS-PTY slot is filled in with a stream
|
||||
connected to pty that can read output and write input.
|
||||
:input -
|
||||
Either T, NIL, a pathname, a stream, or :STREAM. If T, the standard
|
||||
input for the current process is inherited. If NIL, /dev/null
|
||||
is used. If a pathname, the file so specified is used. If a stream,
|
||||
all the input is read from that stream and send to the subprocess. If
|
||||
:STREAM, the PROCESS-INPUT slot is filled in with a stream that sends
|
||||
its output to the process. Defaults to NIL.
|
||||
:if-input-does-not-exist (when :input is the name of a file) -
|
||||
can be one of:
|
||||
:error - generate an error.
|
||||
:create - create an empty file.
|
||||
nil (default) - return nil from run-program.
|
||||
:output -
|
||||
Either T, NIL, a pathname, a stream, or :STREAM. If T, the standard
|
||||
output for the current process is inherited. If NIL, /dev/null
|
||||
is used. If a pathname, the file so specified is used. If a stream,
|
||||
all the output from the process is written to this stream. If
|
||||
:STREAM, the PROCESS-OUTPUT slot is filled in with a stream that can
|
||||
be read to get the output. Defaults to NIL.
|
||||
:if-output-exists (when :input is the name of a file) -
|
||||
can be one of:
|
||||
:error (default) - generates an error if the file already exists.
|
||||
:supersede - output from the program supersedes the file.
|
||||
:append - output from the program is appended to the file.
|
||||
nil - run-program returns nil without doing anything.
|
||||
:error and :if-error-exists -
|
||||
Same as :output and :if-output-exists, except that :error can also be
|
||||
specified as :output in which case all error output is routed to the
|
||||
same place as normal output.
|
||||
:status-hook -
|
||||
This is a function the system calls whenever the status of the
|
||||
process changes. The function takes the process as an argument.
|
||||
Its defined argument types are:
|
||||
(T T &KEY (:ENV T) (:WAIT T) (:PTY T) (:INPUT T) (:IF-INPUT-DOES-NOT-EXIST T)
|
||||
(:OUTPUT T) (:IF-OUTPUT-EXISTS T) (:ERROR T) (:IF-ERROR-EXISTS T)
|
||||
(:STATUS-HOOK T))
|
||||
Its result type is:
|
||||
(OR EXTENSIONS::PROCESS NULL)
|
||||
On Wednesday, 7/1/98 12:48:51 pm [-1] it was compiled from:
|
||||
target:code/run-program.lisp
|
||||
Created: Saturday, 6/20/98 07:13:08 pm [-1]
|
||||
Comment: $Header: /home/david/gitconversion/cvsroot/cxml/glisp/Attic/dep-cmucl.lisp,v 1.1 2005-03-13 18:02:10 david Exp $
|
||||
||#
|
||||
|
||||
;; (process-exit-code (run-program "/bin/sh" (list "-c" "ls") :wait t :input nil :output nil))
|
||||
|
||||
(defun glisp:run-unix-shell-command (command)
|
||||
(ext:process-exit-code (ext:run-program "/bin/sh" (list "-c" command) :wait t :input nil :output nil)))
|
||||
|
||||
(defmacro glisp::defsubst (name args &body body)
|
||||
`(progn
|
||||
(declaim (inline ,name))
|
||||
(defun ,name ,args .,body)))
|
||||
|
||||
|
||||
;;; MP
|
||||
|
||||
(export 'glisp::mp/process-yield :glisp)
|
||||
(export 'glisp::mp/process-wait :glisp)
|
||||
(export 'glisp::mp/process-run-function :glisp)
|
||||
(export 'glisp::mp/make-lock :glisp)
|
||||
(export 'glisp::mp/current-process :glisp)
|
||||
(export 'glisp::mp/process-kill :glisp)
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
(mp:make-lock name))
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
`(mp:with-lock-held (,lock)
|
||||
,@body))
|
||||
|
||||
(defun glisp::mp/process-yield (&optional process-to-run)
|
||||
(declare (ignore process-to-run))
|
||||
(mp:process-yield))
|
||||
|
||||
(defun glisp::mp/process-wait (whostate predicate)
|
||||
(mp:process-wait whostate predicate))
|
||||
|
||||
(defun glisp::mp/process-run-function (name fun &rest args)
|
||||
(mp:make-process
|
||||
(lambda ()
|
||||
(apply fun args))
|
||||
:name name))
|
||||
|
||||
(defun glisp::mp/current-process ()
|
||||
mp:*current-process*)
|
||||
|
||||
(defun glisp::mp/process-kill (process)
|
||||
(mp:destroy-process process))
|
||||
|
||||
(defun glisp::getenv (string)
|
||||
(cdr (assoc string ext:*environment-list* :test #'string-equal)))
|
||||
|
||||
93
glisp/dep-gcl-2.lisp
Normal file
93
glisp/dep-gcl-2.lisp
Normal file
@ -0,0 +1,93 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: GLISP; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: Second part of GCL dependent stuff
|
||||
;;; Created: 1999-05-25 22:31
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(in-package :GLISP)
|
||||
|
||||
(lisp::clines
|
||||
"#include <stdio.h>"
|
||||
"#include <unistd.h>"
|
||||
"#include <sys/stat.h>"
|
||||
"#include <sys/socket.h>"
|
||||
"#include <netinet/in.h>"
|
||||
"#include <stdlib.h>"
|
||||
"#include <fcntl.h>"
|
||||
"#include <resolv.h>"
|
||||
)
|
||||
|
||||
(lisp::defcfun "static object open_inet_socket_aux (object x, object y, char *hostname, int port)" 2
|
||||
"FILE *fp;"
|
||||
"object stream;"
|
||||
|
||||
"struct hostent *hostinfo;"
|
||||
"struct sockaddr_in addr;"
|
||||
"int sock;"
|
||||
"vs_mark;"
|
||||
|
||||
"hostinfo = gethostbyname (hostname);"
|
||||
|
||||
"if (hostinfo == 0)"
|
||||
"{"
|
||||
" return Cnil;"
|
||||
"}"
|
||||
|
||||
"addr.sin_family = AF_INET;"
|
||||
"addr.sin_port = htons (port);"
|
||||
"addr.sin_addr = *(struct in_addr*) hostinfo->h_addr;"
|
||||
""
|
||||
"sock = socket (PF_INET, SOCK_STREAM, 0);"
|
||||
"if (sock < 0)"
|
||||
" return Cnil;"
|
||||
""
|
||||
"if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) != 0)"
|
||||
"{"
|
||||
" close (sock);"
|
||||
" return Cnil;"
|
||||
"}"
|
||||
|
||||
|
||||
"fp = fdopen (sock, \"rb+\");"
|
||||
"stream = (object) alloc_object(t_stream);"
|
||||
"stream->sm.sm_mode = (short)smm_io;"
|
||||
"stream->sm.sm_fp = fp;"
|
||||
"stream->sm.sm_object0 = x;"
|
||||
"stream->sm.sm_object1 = y;"
|
||||
"stream->sm.sm_int0 = stream->sm.sm_int1 = 0;"
|
||||
"vs_push(stream);"
|
||||
"setup_stream_buffer(stream);"
|
||||
"vs_reset;"
|
||||
"return stream;"
|
||||
)
|
||||
|
||||
(lisp::defentry open-inet-socket-aux (lisp::object lisp::object lisp::string lisp::int)
|
||||
(lisp::object "open_inet_socket_aux"))
|
||||
|
||||
(lisp::defentry unix/system (lisp::string)
|
||||
(lisp::int "system"))
|
||||
|
||||
(defun open-inet-socket (hostname port)
|
||||
(values (or (open-inet-socket-aux '(unsigned-byte 8)
|
||||
(format nil "Network connection to ~A:~D" hostname port)
|
||||
hostname port)
|
||||
(error "Cannot connect to `~A' on port ~D."
|
||||
hostname port))
|
||||
:byte))
|
||||
344
glisp/dep-gcl.lisp
Normal file
344
glisp/dep-gcl.lisp
Normal file
@ -0,0 +1,344 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: GCL dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:31
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(shadow '(make-pathname pathname-directory) :glisp)
|
||||
|
||||
(export '(glisp::defun
|
||||
glisp::read-byte-sequence
|
||||
glisp::read-char-sequence
|
||||
glisp::define-compiler-macro
|
||||
glisp::formatter
|
||||
glisp::destructuring-bind
|
||||
glisp::parse-macro
|
||||
glisp::loop
|
||||
glisp::*print-readably*
|
||||
glisp::compile-file-pathname
|
||||
glisp::ignore-errors
|
||||
glisp::pathname-directory
|
||||
glisp::make-pathname
|
||||
glisp::run-unix-shell-command)
|
||||
:glisp)
|
||||
|
||||
(defmacro glisp::defun (name args &body body)
|
||||
(cond ((and (consp name)
|
||||
(eq (car name) 'setf))
|
||||
(let ((fnam (intern (concatenate 'string "(SETF " (symbol-name (cadr name)) ")")
|
||||
(symbol-package (cadr name)))))
|
||||
`(progn
|
||||
(defsetf ,(cadr name) (&rest ap) (new-value) (list* ',fnam new-value ap))
|
||||
(defun ,fnam ,args .,body))))
|
||||
(t
|
||||
`(defun ,name ,args .,body)) ))
|
||||
|
||||
(defun glisp::read-byte-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-byte input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
|
||||
(defun glisp::read-char-sequence (sequence input &key (start 0) (end (length sequence)))
|
||||
(let (c (i start))
|
||||
(loop
|
||||
(cond ((= i end) (return i)))
|
||||
(setq c (read-char input nil :eof))
|
||||
(cond ((eql c :eof) (return i)))
|
||||
(setf (aref sequence i) c)
|
||||
(incf i) )))
|
||||
|
||||
(defmacro glisp::define-compiler-macro (&rest ignore)
|
||||
ignore
|
||||
nil)
|
||||
|
||||
(defun glisp::formatter (string)
|
||||
#'(lambda (sink &rest ap)
|
||||
(apply #'format sink string ap)))
|
||||
|
||||
(defmacro lambda (&rest x)
|
||||
`#'(lambda .,x))
|
||||
|
||||
|
||||
(defun glisp::row-major-aref (array index)
|
||||
;; Wir sollten hier wirklich was effizienteres haben
|
||||
(aref (make-array (array-total-size array)
|
||||
:displaced-to array
|
||||
:element-type (array-element-type array))
|
||||
index))
|
||||
|
||||
(glisp::defun (setf glisp::row-major-aref) (value array index)
|
||||
;; Wir sollten hier wirklich was effizienteres haben
|
||||
(setf (aref (make-array (array-total-size array)
|
||||
:displaced-to array
|
||||
:element-type (array-element-type array))
|
||||
index)
|
||||
value))
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
name
|
||||
nil)
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
(declare (ignore lock))
|
||||
`(progn
|
||||
,@body))
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest ignore) &body body)
|
||||
(declare (ignore ignore))
|
||||
`(progn
|
||||
,@body))
|
||||
|
||||
(defvar glisp::*print-readably* nil)
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length :element-type 'string-char options))
|
||||
|
||||
(defun parse-macro-lambda-list (name lambda-list whole &optional environment-value (real-whole whole))
|
||||
"The work horse for destructing-bind and parse-macro."
|
||||
(let ((orig-lambda-list lambda-list)
|
||||
required optionals rest-var keys aux-vars whole-var env-var
|
||||
allow-other-keys-p
|
||||
(my-lambda-list-keywords '(&OPTIONAL &REST &KEY &AUX &BODY)))
|
||||
|
||||
(labels ((COLLECT (&optional on-keys-p)
|
||||
(let (result)
|
||||
(do ()
|
||||
((or (atom lambda-list) (member (car lambda-list) my-lambda-list-keywords))
|
||||
(nreverse result))
|
||||
(cond ((eq (car lambda-list) '&WHOLE)
|
||||
(push (cadr lambda-list) whole-var)
|
||||
(setf lambda-list (cddr lambda-list)))
|
||||
((eq (car lambda-list) '&ENVIRONMENT)
|
||||
(push (cadr lambda-list) env-var)
|
||||
(setf lambda-list (cddr lambda-list)))
|
||||
((eq (car lambda-list) '&ALLOW-OTHER-KEYS)
|
||||
(unless on-keys-p
|
||||
(cerror "Ignore this syntax restriction and set the allow-other-keys-p flag."
|
||||
"In lambda list of macro ~S: &ALLOW-OTHER-KEYS may only be specified ~
|
||||
in the &KEYS section: ~S"
|
||||
name orig-lambda-list))
|
||||
(setq allow-other-keys-p T lambda-list (cdr lambda-list)))
|
||||
(T (push (pop lambda-list) result)) ))) )
|
||||
|
||||
(CHECK-ONLY-ONE (kind lst)
|
||||
(unless (<= (length lst) 1)
|
||||
(error "In lambda list of macro ~S: You may only specify one ~S parameter, but I got ~S.~%~
|
||||
Lambda list: ~S."
|
||||
name kind lst orig-lambda-list))
|
||||
(car lst)) )
|
||||
|
||||
;; Now collect the various elements of the lambda-list
|
||||
(setq required (collect))
|
||||
(when (and (consp lambda-list) (eq (car lambda-list) '&OPTIONAL)) (pop lambda-list) (setq optionals (collect)))
|
||||
(when (and (consp lambda-list) (member (car lambda-list) '(&REST &BODY))) (pop lambda-list) (setq rest-var (collect)))
|
||||
(when (and (consp lambda-list) (eq (car lambda-list) '&KEY)) (pop lambda-list) (setq keys (collect T)))
|
||||
(when (and (consp lambda-list) (eq (car lambda-list) '&AUX)) (pop lambda-list) (setq aux-vars (collect)))
|
||||
|
||||
;; Inspect the remaining value of lambda-list
|
||||
(cond ((consp lambda-list)
|
||||
;; Not all was parsed correctly ...
|
||||
(error "In lambda list of macro ~S: Found lambda list keyword ~S out of order;~%~
|
||||
The order must be &OPTIONAL, &REST/&BODY, &KEY, &AUX; &WHOLE and &ENVIRONMENT may apear anywhere.~%~
|
||||
Lambda list: ~S."
|
||||
name (car lambda-list) orig-lambda-list))
|
||||
((null lambda-list)) ; Everything is just fine.
|
||||
((symbolp lambda-list)
|
||||
;; Dotted with a symbol = specification of a rest-var
|
||||
(push lambda-list rest-var))
|
||||
(T
|
||||
;; List is odd-ly dotted.
|
||||
(error "In lambda list of macro ~S: A lambda list may only be dotted with a symbol.~%~
|
||||
Lambda list: ~S."
|
||||
name orig-lambda-list)) )
|
||||
|
||||
;; Now check for rest-var, whole-var and env-var, which may all specify only one variable ...
|
||||
(setf rest-var (check-only-one '&REST rest-var))
|
||||
(setf whole-var (check-only-one '&WHOLE whole-var))
|
||||
(when (and env-var (not environment-value))
|
||||
(cerror "Ignore the &ENVIRONMENT parameter."
|
||||
"In lambda list of macro ~S: An &ENVIRONMENT parameter may only be specified on the top-level lambda list.~%~
|
||||
Lambda list: ~S."
|
||||
name orig-lambda-list)
|
||||
(setq env-var nil))
|
||||
(setf env-var (check-only-one '&ENVIRONMENT env-var))
|
||||
|
||||
(when (and (null rest-var) keys)
|
||||
(setf rest-var (gensym)))
|
||||
|
||||
;; Build up the bindings
|
||||
(let ((bindings nil) (constraints nil) (w whole))
|
||||
(labels ((add-one (x) (add (list x)))
|
||||
(add-bind (spec val)
|
||||
(if (consp spec)
|
||||
(let ((gsym (gensym)))
|
||||
(add-one `(,gsym ,val))
|
||||
(multiple-value-bind (bndngs cnstrnts) (parse-macro-lambda-list name spec gsym)
|
||||
(add bndngs)
|
||||
(setq contraints (nconc constraints cnstrnts))) )
|
||||
(add-one `(,spec ,val))))
|
||||
(add (x) (setf bindings (nconc bindings x))))
|
||||
|
||||
(when whole-var
|
||||
(add-one `(,whole-var ,real-whole))
|
||||
(when (eq whole real-whole) (setq w whole-var)))
|
||||
|
||||
;; Calculate the constraints ...
|
||||
(let ((min nil)
|
||||
(max nil))
|
||||
(when (or required optionals rest-var) (setq min (length required)))
|
||||
(when (and (null rest-var) (or required optionals))
|
||||
(setq max (+ (length required) (length optionals))))
|
||||
(cond ((and (null min) (null max)))
|
||||
((eql min max)
|
||||
(push `(listp ,w) constraints)
|
||||
(push `(= (length ,w) ,min) constraints))
|
||||
(T
|
||||
(push `(listp ,w) constraints)
|
||||
(when (and min (> min 0)) (push `(>= (length ,w) ,min) constraints))
|
||||
(when max (push `(<= (length ,w) ,max) constraints))) ))
|
||||
|
||||
(setq constraints (nreverse constraints))
|
||||
|
||||
(dolist (spec required)
|
||||
(add-bind spec `(CAR ,w))
|
||||
(setf w (list 'cdr w)))
|
||||
|
||||
(dolist (spec optionals)
|
||||
;; CHECK
|
||||
(cond ((consp spec)
|
||||
(when (caddr spec) ;svar
|
||||
(add-one `(,(caddr spec) (NOT (NULL ,w)))))
|
||||
(add-bind (car spec) `(if (NOT (NULL ,w)) (CAR ,w) ,(cadr spec))))
|
||||
(T
|
||||
(add-one `(,spec (CAR ,w)))) )
|
||||
(setf w (list 'cdr w)))
|
||||
|
||||
(when rest-var (add-one `(,rest-var ,w)))
|
||||
|
||||
(dolist (spec keys)
|
||||
;; CHECK
|
||||
(let (kw var svar default)
|
||||
(cond ((consp spec)
|
||||
(setq var (car spec) default (cadr spec) svar (caddr spec))
|
||||
(when (consp var) (setq kw (car var) var (cadr var))))
|
||||
(T (setq var spec default nil svar nil)))
|
||||
;; SVAR
|
||||
(unless kw (setq kw (intern (symbol-name var) :keyword)))
|
||||
(add-bind var `(getf ,rest-var ,kw ,default)) ))
|
||||
|
||||
(dolist (spec aux-vars) (add-one spec))
|
||||
|
||||
(when env-var
|
||||
(add-one `(,env-var ,environment-value)))
|
||||
|
||||
(values bindings constraints env-var)) ))))
|
||||
|
||||
(defun glisp::parse-macro (name lambda-list body &optional env)
|
||||
"This is used to process a macro definition in the same way as defmacro and
|
||||
macrolet. It returns a lambda-expression that accepts two arguments, a form
|
||||
and an environment. The name, lambda-list, and body arguments correspond to
|
||||
the parts of a defmacro or macrolet definition.
|
||||
|
||||
The lambda-list argument may inclue &environment and &whole and may include
|
||||
destructing. The name argument is used to enclose the body in an implicat
|
||||
block and might also be used for implementation-depend purposes (such as
|
||||
including the name of the macro in error messages if the form does not match
|
||||
the lambda-list)."
|
||||
|
||||
(let ((call (gensym)) (env (gensym)))
|
||||
(multiple-value-bind (bindings constraints)
|
||||
(parse-macro-lambda-list name lambda-list `(CDR call) env call)
|
||||
`(lambda (,call ,env)
|
||||
(block ,name
|
||||
(let* ,bindings
|
||||
(unless (and ,@constraints)
|
||||
(error "Macro ~S called with wrong number/nesting of arguments: ~S"
|
||||
',name ,call))
|
||||
,@body))) )) )
|
||||
|
||||
(defmacro glisp::destructuring-bind (lambda-list expression &body body)
|
||||
"This macro binds the variables specified in lambda-list to the corresponding
|
||||
values in the tree structure resulting from evaluating the expression, then
|
||||
executes the forms as an implicit progn.
|
||||
|
||||
A destructing-bind lambda-list may contain the lambda-list keywords &optional,
|
||||
&rest, &key, &allow-other-keys, and &aux; &body and &whole may also be used as
|
||||
they are in defmacro, but &environment may not be used. Nested and dotted
|
||||
lambda-lists are also permitted as for defmacro. The idea is that a
|
||||
destructing-bind lambda-list has the same format as inner levels of a defmacro
|
||||
lambda-list.
|
||||
|
||||
If the result of evaluating the expressions does not match the destructuring
|
||||
pattern, an error should be signaled."
|
||||
|
||||
(let ((call (gensym)))
|
||||
(multiple-value-bind (bindings constraints)
|
||||
(parse-macro-lambda-list nil lambda-list call)
|
||||
`(let* ((,call ,expression) ,@bindings)
|
||||
(unless (and ,@constraints)
|
||||
(error "DESTRUCTING-BIND with wrong number/nesting of arguments: ~S~%~
|
||||
Lambda list to match with: ~S." ,call ',lambda-list))
|
||||
(locally ,@body)) )) )
|
||||
|
||||
|
||||
(defmacro glisp::loop (&rest args)
|
||||
`(sloop:sloop ,@args))
|
||||
|
||||
(defun glisp:compile-file-pathname (filename &rest options)
|
||||
(declare (ignore options))
|
||||
(merge-pathnames (make-pathname :type "o") filename))
|
||||
|
||||
|
||||
(defmacro glisp:ignore-errors (&rest body)
|
||||
`(IGNORE-ERRORS-FN #'(LAMBDA () ,@body)))
|
||||
|
||||
(defun ignore-errors-fn (cont)
|
||||
(let ((old (symbol-function 'system:universal-error-handler)))
|
||||
(block foo
|
||||
(unwind-protect
|
||||
(progn
|
||||
(setf (symbol-function 'system:universal-error-handler)
|
||||
#'(lambda (&rest x)
|
||||
(return-from foo (values nil x))))
|
||||
(funcall cont) )
|
||||
(setf (symbol-function 'system:universal-error-handler) old) ))))
|
||||
|
||||
(defun glisp::make-pathname (&rest args &key directory &allow-other-keys)
|
||||
(cond ((eq (car directory) :relative)
|
||||
(apply #'lisp:make-pathname :directory (cdr directory) args))
|
||||
((eq (car directory) :absolute)
|
||||
(apply #'lisp:make-pathname :directory (cons :root (cdr directory)) args))
|
||||
(t
|
||||
(apply #'lisp:make-pathname args))))
|
||||
|
||||
(defun glisp::pathname-directory (pathname)
|
||||
(let ((d (lisp:pathname-directory pathname)))
|
||||
(cond ((eq (car d) :root)
|
||||
(cons :absolute (cdr d)))
|
||||
(t
|
||||
(cons :relative d)))))
|
||||
|
||||
|
||||
(defun glisp::run-unix-shell-command (cmd)
|
||||
(glisp::unix/system cmd))
|
||||
141
glisp/dep-sbcl.lisp
Normal file
141
glisp/dep-sbcl.lisp
Normal file
@ -0,0 +1,141 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: SBCL dependent stuff + fixups
|
||||
;;; Created: 1999-05-25 22:32
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
(export 'glisp::read-byte-sequence :glisp)
|
||||
(export 'glisp::read-char-sequence :glisp)
|
||||
(export 'glisp::run-unix-shell-command :glisp)
|
||||
|
||||
(export 'glisp::getenv :glisp)
|
||||
|
||||
(export 'glisp::make-server-socket :glisp)
|
||||
(export 'glisp::close-server-socket :glisp)
|
||||
|
||||
(defun glisp::read-byte-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defun glisp::read-char-sequence (&rest ap)
|
||||
(apply #'read-sequence ap))
|
||||
|
||||
(defmacro glisp::with-timeout ((&rest options) &body body)
|
||||
(declare (ignore ignore))
|
||||
`(progn
|
||||
,@body))
|
||||
|
||||
(defun glisp::open-inet-socket (hostname port)
|
||||
(values
|
||||
(sb-bsd-sockets:socket-make-stream
|
||||
(let ((host (car (sb-bsd-sockets:host-ent-addresses
|
||||
(sb-bsd-sockets:get-host-by-name hostname)))))
|
||||
(when host
|
||||
(let ((s (make-instance 'sb-bsd-sockets:inet-socket
|
||||
:type :stream :protocol :tcp)))
|
||||
(sb-bsd-sockets:socket-connect s host port)
|
||||
s)))
|
||||
:element-type '(unsigned-byte 8)
|
||||
:input t :output t)
|
||||
:byte))
|
||||
|
||||
(defstruct (server-socket (:constructor make-server-socket-struct))
|
||||
fd
|
||||
element-type
|
||||
port)
|
||||
|
||||
|
||||
#||
|
||||
(defun glisp::make-server-socket (port &key (element-type '(unsigned-byte 8)))
|
||||
(make-server-socket-struct :fd (ext:create-inet-listener port)
|
||||
:element-type element-type
|
||||
:port port))
|
||||
|
||||
|
||||
(defun glisp::accept-connection/low (socket)
|
||||
(mp:process-wait-until-fd-usable (server-socket-fd socket) :input)
|
||||
(values
|
||||
(sys:make-fd-stream (ext:accept-tcp-connection (server-socket-fd socket))
|
||||
:input t :output t
|
||||
:element-type (server-socket-element-type socket))
|
||||
(cond ((subtypep (server-socket-element-type socket) 'integer)
|
||||
:byte)
|
||||
(t
|
||||
:char))))
|
||||
|
||||
(defun glisp::close-server-socket (socket)
|
||||
(unix:unix-close (server-socket-fd socket)))
|
||||
||#
|
||||
|
||||
;;;;;;
|
||||
|
||||
(defun glisp::g/make-string (length &rest options)
|
||||
(apply #'make-array length :element-type 'base-char options))
|
||||
|
||||
|
||||
|
||||
(defun glisp::run-unix-shell-command (command)
|
||||
(sb-impl::process-exit-code
|
||||
(sb-ext:run-program "/bin/sh" (list "-c" command) :wait t :input nil
|
||||
:output nil)))
|
||||
|
||||
(defmacro glisp::defsubst (name args &body body)
|
||||
`(progn
|
||||
(declaim (inline ,name))
|
||||
(defun ,name ,args .,body)))
|
||||
|
||||
|
||||
;;; MP
|
||||
|
||||
(export 'glisp::mp/process-yield :glisp)
|
||||
(export 'glisp::mp/process-wait :glisp)
|
||||
(export 'glisp::mp/process-run-function :glisp)
|
||||
(export 'glisp::mp/make-lock :glisp)
|
||||
(export 'glisp::mp/current-process :glisp)
|
||||
(export 'glisp::mp/process-kill :glisp)
|
||||
|
||||
(defun glisp::mp/make-lock (&key name)
|
||||
(clim-sys::make-lock name))
|
||||
|
||||
(defmacro glisp::mp/with-lock ((lock) &body body)
|
||||
`(clim-sys:with-lock-held (,lock)
|
||||
,@body))
|
||||
|
||||
(defun glisp::mp/process-yield (&optional process-to-run)
|
||||
(declare (ignore process-to-run))
|
||||
(clim-sys:process-yield))
|
||||
|
||||
(defun glisp::mp/process-wait (whostate predicate)
|
||||
(clim-sys:process-wait whostate predicate))
|
||||
|
||||
(defun glisp::mp/process-run-function (name fun &rest args)
|
||||
(clim-sys:make-process
|
||||
(lambda ()
|
||||
(apply fun args))
|
||||
:name name))
|
||||
|
||||
(defun glisp::mp/current-process ()
|
||||
(clim-sys:current-process))
|
||||
|
||||
(defun glisp::mp/process-kill (process)
|
||||
(clim-sys:destroy-process process))
|
||||
|
||||
(defun glisp::getenv (string)
|
||||
(sb-ext:posix-getenv string))
|
||||
|
||||
427
glisp/gendep.lisp
Normal file
427
glisp/gendep.lisp
Normal file
@ -0,0 +1,427 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: CL-USER; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: Generating a sane DEFPACKAGE for GLISP
|
||||
;;; Created: 1999-05-25 22:30
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
(defparameter *all-ansi-symbols*
|
||||
'("&ALLOW-OTHER-KEYS" "&AUX" "&BODY" "&ENVIRONMENT" "&KEY" "&OPTIONAL" "&REST" "&WHOLE" "*"
|
||||
"**" "***" "*BREAK-ON-SIGNALS*" "*COMPILE-FILE-PATHNAME*" "*COMPILE-FILE-TRUENAME*"
|
||||
"*COMPILE-PRINT*" "*COMPILE-VERBOSE*" "*DEBUG-IO*" "*DEBUGGER-HOOK*"
|
||||
"*DEFAULT-PATHNAME-DEFAULTS*" "*ERROR-OUTPUT*" "*FEATURES*" "*GENSYM-COUNTER*"
|
||||
"*LOAD-PATHNAME*" "*LOAD-PRINT*" "*LOAD-TRUENAME*" "*LOAD-VERBOSE*" "*MACROEXPAND-HOOK*"
|
||||
"*MODULES*" "*PACKAGE*" "*PRINT-ARRAY*" "*PRINT-BASE*" "*PRINT-CASE*" "*PRINT-CIRCLE*"
|
||||
"*PRINT-ESCAPE*" "*PRINT-GENSYM*" "*PRINT-LENGTH*" "*PRINT-LEVEL*" "*PRINT-LINES*"
|
||||
"*PRINT-MISER-WIDTH*" "*PRINT-PPRINT-DISPATCH*" "*PRINT-PRETTY*" "*PRINT-RADIX*"
|
||||
"*PRINT-READABLY*" "*PRINT-RIGHT-MARGIN*" "*QUERY-IO*" "*RANDOM-STATE*" "*READ-BASE*"
|
||||
"*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*"
|
||||
"*STANDARD-INPUT*" "*STANDARD-OUTPUT*" "*TERMINAL-IO*" "*TRACE-OUTPUT*" "+" "++" "+++" "-"
|
||||
"/" "//" "///" "/=" "1+" "1-" "<" "<=" "=" ">" ">=" "ABORT" "ABS" "ACONS" "ACOS" "ACOSH"
|
||||
"ADD-METHOD" "ADJOIN" "ADJUST-ARRAY" "ADJUSTABLE-ARRAY-P" "ALLOCATE-INSTANCE"
|
||||
"ALPHA-CHAR-P" "ALPHANUMERICP" "AND" "APPEND" "APPLY" "APROPOS" "APROPOS-LIST" "AREF"
|
||||
"ARITHMETIC-ERROR" "ARITHMETIC-ERROR-OPERANDS" "ARITHMETIC-ERROR-OPERATION" "ARRAY"
|
||||
"ARRAY-DIMENSION" "ARRAY-DIMENSION-LIMIT" "ARRAY-DIMENSIONS" "ARRAY-DISPLACEMENT"
|
||||
"ARRAY-ELEMENT-TYPE" "ARRAY-HAS-FILL-POINTER-P" "ARRAY-IN-BOUNDS-P" "ARRAY-RANK"
|
||||
"ARRAY-RANK-LIMIT" "ARRAY-ROW-MAJOR-INDEX" "ARRAY-TOTAL-SIZE" "ARRAY-TOTAL-SIZE-LIMIT"
|
||||
"ARRAYP" "ASH" "ASIN" "ASINH" "ASSERT" "ASSOC" "ASSOC-IF" "ASSOC-IF-NOT" "ATAN" "ATANH"
|
||||
"ATOM" "BASE-CHAR" "BASE-STRING" "BIGNUM" "BIT" "BIT-AND" "BIT-ANDC1" "BIT-ANDC2"
|
||||
"BIT-EQV" "BIT-IOR" "BIT-NAND" "BIT-NOR" "BIT-NOT" "BIT-ORC1" "BIT-ORC2" "BIT-VECTOR"
|
||||
"BIT-VECTOR-P" "BIT-XOR" "BLOCK" "BOOLE" "BOOLE-1" "BOOLE-2" "BOOLE-AND" "BOOLE-ANDC1"
|
||||
"BOOLE-ANDC2" "BOOLE-C1" "BOOLE-C2" "BOOLE-CLR" "BOOLE-EQV" "BOOLE-IOR" "BOOLE-NAND"
|
||||
"BOOLE-NOR" "BOOLE-ORC1" "BOOLE-ORC2" "BOOLE-SET" "BOOLE-XOR" "BOOLEAN" "BOTH-CASE-P"
|
||||
"BOUNDP" "BREAK" "BROADCAST-STREAM" "BROADCAST-STREAM-STREAMS" "BUILT-IN-CLASS" "BUTLAST"
|
||||
"BYTE" "BYTE-POSITION" "BYTE-SIZE" "CAAAAR" "CAAADR" "CAAAR" "CAADAR" "CAADDR" "CAADR"
|
||||
"CAAR" "CADAAR" "CADADR" "CADAR" "CADDAR" "CADDDR" "CADDR" "CADR" "CALL-ARGUMENTS-LIMIT"
|
||||
"CALL-METHOD" "CALL-NEXT-METHOD" "CAR" "CASE" "CATCH" "CCASE" "CDAAAR" "CDAADR" "CDAAR"
|
||||
"CDADAR" "CDADDR" "CDADR" "CDAR" "CDDAAR" "CDDADR" "CDDAR" "CDDDAR" "CDDDDR" "CDDDR"
|
||||
"CDDR" "CDR" "CEILING" "CELL-ERROR" "CELL-ERROR-NAME" "CERROR" "CHANGE-CLASS" "CHAR"
|
||||
"CHAR-CODE" "CHAR-CODE-LIMIT" "CHAR-DOWNCASE" "CHAR-EQUAL" "CHAR-GREATERP" "CHAR-INT"
|
||||
"CHAR-LESSP" "CHAR-NAME" "CHAR-NOT-EQUAL" "CHAR-NOT-GREATERP" "CHAR-NOT-LESSP"
|
||||
"CHAR-UPCASE" "CHAR/=" "CHAR<" "CHAR<=" "CHAR=" "CHAR>" "CHAR>=" "CHARACTER" "CHARACTERP"
|
||||
"CHECK-TYPE" "CIS" "CLASS" "CLASS-NAME" "CLASS-OF" "CLEAR-INPUT" "CLEAR-OUTPUT" "CLOSE"
|
||||
"CLRHASH" "CODE-CHAR" "COERCE" "COMPILATION-SPEED" "COMPILE" "COMPILE-FILE"
|
||||
"COMPILE-FILE-PATHNAME" "COMPILED-FUNCTION" "COMPILED-FUNCTION-P" "COMPILER-MACRO"
|
||||
"COMPILER-MACRO-FUNCTION" "COMPLEMENT" "COMPLEX" "COMPLEXP" "COMPUTE-APPLICABLE-METHODS"
|
||||
"COMPUTE-RESTARTS" "CONCATENATE" "CONCATENATED-STREAM" "CONCATENATED-STREAM-STREAMS"
|
||||
"COND" "CONDITION" "CONJUGATE" "CONS" "CONSP" "CONSTANTLY" "CONSTANTP" "CONTINUE"
|
||||
"CONTROL-ERROR" "COPY-ALIST" "COPY-LIST" "COPY-PPRINT-DISPATCH" "COPY-READTABLE"
|
||||
"COPY-SEQ" "COPY-STRUCTURE" "COPY-SYMBOL" "COPY-TREE" "COS" "COSH" "COUNT" "COUNT-IF"
|
||||
"COUNT-IF-NOT" "CTYPECASE" "DEBUG" "DECF" "DECLAIM" "DECLARATION" "DECLARE" "DECODE-FLOAT"
|
||||
"DECODE-UNIVERSAL-TIME" "DEFCLASS" "DEFCONSTANT" "DEFGENERIC" "DEFINE-COMPILER-MACRO"
|
||||
"DEFINE-CONDITION" "DEFINE-METHOD-COMBINATION" "DEFINE-MODIFY-MACRO"
|
||||
"DEFINE-SETF-EXPANDER" "DEFINE-SYMBOL-MACRO" "DEFMACRO" "DEFMETHOD" "DEFPACKAGE"
|
||||
"DEFPARAMETER" "DEFSETF" "DEFSTRUCT" "DEFTYPE" "DEFUN" "DEFVAR" "DELETE"
|
||||
"DELETE-DUPLICATES" "DELETE-FILE" "DELETE-IF" "DELETE-IF-NOT" "DELETE-PACKAGE"
|
||||
"DENOMINATOR" "DEPOSIT-FIELD" "DESCRIBE" "DESCRIBE-OBJECT" "DESTRUCTURING-BIND"
|
||||
"DIGIT-CHAR" "DIGIT-CHAR-P" "DIRECTORY" "DIRECTORY-NAMESTRING" "DISASSEMBLE"
|
||||
"DIVISION-BY-ZERO" "DO" "DO*" "DO-ALL-SYMBOLS" "DO-EXTERNAL-SYMBOLS" "DO-SYMBOLS"
|
||||
"DOCUMENTATION" "DOLIST" "DOTIMES" "DOUBLE-FLOAT" "DOUBLE-FLOAT-EPSILON"
|
||||
"DOUBLE-FLOAT-NEGATIVE-EPSILON" "DPB" "DRIBBLE" "DYNAMIC-EXTENT" "ECASE" "ECHO-STREAM"
|
||||
"ECHO-STREAM-INPUT-STREAM" "ECHO-STREAM-OUTPUT-STREAM" "ED" "EIGHTH" "ELT"
|
||||
"ENCODE-UNIVERSAL-TIME" "END-OF-FILE" "ENDP" "ENOUGH-NAMESTRING"
|
||||
"ENSURE-DIRECTORIES-EXIST" "ENSURE-GENERIC-FUNCTION" "EQ" "EQL" "EQUAL" "EQUALP" "ERROR"
|
||||
"ETYPECASE" "EVAL" "EVAL-WHEN" "EVENP" "EVERY" "EXP" "EXPORT" "EXPT" "EXTENDED-CHAR"
|
||||
"FBOUNDP" "FCEILING" "FDEFINITION" "FFLOOR" "FIFTH" "FILE-AUTHOR" "FILE-ERROR"
|
||||
"FILE-ERROR-PATHNAME" "FILE-LENGTH" "FILE-NAMESTRING" "FILE-POSITION" "FILE-STREAM"
|
||||
"FILE-STRING-LENGTH" "FILE-WRITE-DATE" "FILL" "FILL-POINTER" "FIND" "FIND-ALL-SYMBOLS"
|
||||
"FIND-CLASS" "FIND-IF" "FIND-IF-NOT" "FIND-METHOD" "FIND-PACKAGE" "FIND-RESTART"
|
||||
"FIND-SYMBOL" "FINISH-OUTPUT" "FIRST" "FIXNUM" "FLET" "FLOAT" "FLOAT-DIGITS"
|
||||
"FLOAT-PRECISION" "FLOAT-RADIX" "FLOAT-SIGN" "FLOATING-POINT-INEXACT"
|
||||
"FLOATING-POINT-INVALID-OPERATION" "FLOATING-POINT-OVERFLOW" "FLOATING-POINT-UNDERFLOW"
|
||||
"FLOATP" "FLOOR" "FMAKUNBOUND" "FORCE-OUTPUT" "FORMAT" "FORMATTER" "FOURTH" "FRESH-LINE"
|
||||
"FROUND" "FTRUNCATE" "FTYPE" "FUNCALL" "FUNCTION" "FUNCTION-KEYWORDS"
|
||||
"FUNCTION-LAMBDA-EXPRESSION" "FUNCTIONP" "GCD" "GENERIC-FUNCTION" "GENSYM" "GENTEMP" "GET"
|
||||
"GET-DECODED-TIME" "GET-DISPATCH-MACRO-CHARACTER" "GET-INTERNAL-REAL-TIME"
|
||||
"GET-INTERNAL-RUN-TIME" "GET-MACRO-CHARACTER" "GET-OUTPUT-STREAM-STRING" "GET-PROPERTIES"
|
||||
"GET-SETF-EXPANSION" "GET-UNIVERSAL-TIME" "GETF" "GETHASH" "GO" "GRAPHIC-CHAR-P"
|
||||
"HANDLER-BIND" "HANDLER-CASE" "HASH-TABLE" "HASH-TABLE-COUNT" "HASH-TABLE-P"
|
||||
"HASH-TABLE-REHASH-SIZE" "HASH-TABLE-REHASH-THRESHOLD" "HASH-TABLE-SIZE" "HASH-TABLE-TEST"
|
||||
"HOST-NAMESTRING" "IDENTITY" "IF" "IGNORABLE" "IGNORE" "IGNORE-ERRORS" "IMAGPART" "IMPORT"
|
||||
"IN-PACKAGE" "INCF" "INITIALIZE-INSTANCE" "INLINE" "INPUT-STREAM-P" "INSPECT" "INTEGER"
|
||||
"INTEGER-DECODE-FLOAT" "INTEGER-LENGTH" "INTEGERP" "INTERACTIVE-STREAM-P" "INTERN"
|
||||
"INTERNAL-TIME-UNITS-PER-SECOND" "INTERSECTION" "INVALID-METHOD-ERROR" "INVOKE-DEBUGGER"
|
||||
"INVOKE-RESTART" "INVOKE-RESTART-INTERACTIVELY" "ISQRT" "KEYWORD" "KEYWORDP" "LABELS"
|
||||
"LAMBDA" "LAMBDA-LIST-KEYWORDS" "LAMBDA-PARAMETERS-LIMIT" "LAST" "LCM" "LDB" "LDB-TEST"
|
||||
"LDIFF" "LEAST-NEGATIVE-DOUBLE-FLOAT" "LEAST-NEGATIVE-LONG-FLOAT"
|
||||
"LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT" "LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT"
|
||||
"LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT" "LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT"
|
||||
"LEAST-NEGATIVE-SHORT-FLOAT" "LEAST-NEGATIVE-SINGLE-FLOAT" "LEAST-POSITIVE-DOUBLE-FLOAT"
|
||||
"LEAST-POSITIVE-LONG-FLOAT" "LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT"
|
||||
"LEAST-POSITIVE-NORMALIZED-LONG-FLOAT" "LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT"
|
||||
"LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT" "LEAST-POSITIVE-SHORT-FLOAT"
|
||||
"LEAST-POSITIVE-SINGLE-FLOAT" "LENGTH" "LET" "LET*" "LISP-IMPLEMENTATION-TYPE"
|
||||
"LISP-IMPLEMENTATION-VERSION" "LIST" "LIST*" "LIST-ALL-PACKAGES" "LIST-LENGTH" "LISTEN"
|
||||
"LISTP" "LOAD" "LOAD-LOGICAL-PATHNAME-TRANSLATIONS" "LOAD-TIME-VALUE" "LOCALLY" "LOG"
|
||||
"LOGAND" "LOGANDC1" "LOGANDC2" "LOGBITP" "LOGCOUNT" "LOGEQV" "LOGICAL-PATHNAME"
|
||||
"LOGICAL-PATHNAME-TRANSLATIONS" "LOGIOR" "LOGNAND" "LOGNOR" "LOGNOT" "LOGORC1" "LOGORC2"
|
||||
"LOGTEST" "LOGXOR" "LONG-FLOAT" "LONG-FLOAT-EPSILON" "LONG-FLOAT-NEGATIVE-EPSILON"
|
||||
"LONG-SITE-NAME" "LOOP" "LOOP-FINISH" "LOWER-CASE-P" "MACHINE-INSTANCE" "MACHINE-TYPE"
|
||||
"MACHINE-VERSION" "MACRO-FUNCTION" "MACROEXPAND" "MACROEXPAND-1" "MACROLET" "MAKE-ARRAY"
|
||||
"MAKE-BROADCAST-STREAM" "MAKE-CONCATENATED-STREAM" "MAKE-CONDITION"
|
||||
"MAKE-DISPATCH-MACRO-CHARACTER" "MAKE-ECHO-STREAM" "MAKE-HASH-TABLE" "MAKE-INSTANCE"
|
||||
"MAKE-INSTANCES-OBSOLETE" "MAKE-LIST" "MAKE-LOAD-FORM" "MAKE-LOAD-FORM-SAVING-SLOTS"
|
||||
"MAKE-METHOD" "MAKE-PACKAGE" "MAKE-PATHNAME" "MAKE-RANDOM-STATE" "MAKE-SEQUENCE"
|
||||
"MAKE-STRING" "MAKE-STRING-INPUT-STREAM" "MAKE-STRING-OUTPUT-STREAM" "MAKE-SYMBOL"
|
||||
"MAKE-SYNONYM-STREAM" "MAKE-TWO-WAY-STREAM" "MAKUNBOUND" "MAP" "MAP-INTO" "MAPC" "MAPCAN"
|
||||
"MAPCAR" "MAPCON" "MAPHASH" "MAPL" "MAPLIST" "MASK-FIELD" "MAX" "MEMBER" "MEMBER-IF"
|
||||
"MEMBER-IF-NOT" "MERGE" "MERGE-PATHNAMES" "METHOD" "METHOD-COMBINATION"
|
||||
"METHOD-COMBINATION-ERROR" "METHOD-QUALIFIERS" "MIN" "MINUSP" "MISMATCH" "MOD"
|
||||
"MOST-NEGATIVE-DOUBLE-FLOAT" "MOST-NEGATIVE-FIXNUM" "MOST-NEGATIVE-LONG-FLOAT"
|
||||
"MOST-NEGATIVE-SHORT-FLOAT" "MOST-NEGATIVE-SINGLE-FLOAT" "MOST-POSITIVE-DOUBLE-FLOAT"
|
||||
"MOST-POSITIVE-FIXNUM" "MOST-POSITIVE-LONG-FLOAT" "MOST-POSITIVE-SHORT-FLOAT"
|
||||
"MOST-POSITIVE-SINGLE-FLOAT" "MUFFLE-WARNING" "MULTIPLE-VALUE-BIND" "MULTIPLE-VALUE-CALL"
|
||||
"MULTIPLE-VALUE-LIST" "MULTIPLE-VALUE-PROG1" "MULTIPLE-VALUE-SETQ" "MULTIPLE-VALUES-LIMIT"
|
||||
"NAME-CHAR" "NAMESTRING" "NBUTLAST" "NCONC" "NEXT-METHOD-P" "NIL" "NINTERSECTION" "NINTH"
|
||||
"NO-APPLICABLE-METHOD" "NO-NEXT-METHOD" "NOT" "NOTANY" "NOTEVERY" "NOTINLINE" "NRECONC"
|
||||
"NREVERSE" "NSET-DIFFERENCE" "NSET-EXCLUSIVE-OR" "NSTRING-CAPITALIZE" "NSTRING-DOWNCASE"
|
||||
"NSTRING-UPCASE" "NSUBLIS" "NSUBST" "NSUBST-IF" "NSUBST-IF-NOT" "NSUBSTITUTE"
|
||||
"NSUBSTITUTE-IF" "NSUBSTITUTE-IF-NOT" "NTH" "NTH-VALUE" "NTHCDR" "NULL" "NUMBER" "NUMBERP"
|
||||
"NUMERATOR" "NUNION" "ODDP" "OPEN" "OPEN-STREAM-P" "OPTIMIZE" "OR" "OTHERWISE"
|
||||
"OUTPUT-STREAM-P" "PACKAGE" "PACKAGE-ERROR" "PACKAGE-ERROR-PACKAGE" "PACKAGE-NAME"
|
||||
"PACKAGE-NICKNAMES" "PACKAGE-SHADOWING-SYMBOLS" "PACKAGE-USE-LIST" "PACKAGE-USED-BY-LIST"
|
||||
"PACKAGEP" "PAIRLIS" "PARSE-ERROR" "PARSE-INTEGER" "PARSE-NAMESTRING" "PATHNAME"
|
||||
"PATHNAME-DEVICE" "PATHNAME-DIRECTORY" "PATHNAME-HOST" "PATHNAME-MATCH-P" "PATHNAME-NAME"
|
||||
"PATHNAME-TYPE" "PATHNAME-VERSION" "PATHNAMEP" "PEEK-CHAR" "PHASE" "PI" "PLUSP" "POP"
|
||||
"POSITION" "POSITION-IF" "POSITION-IF-NOT" "PPRINT" "PPRINT-DISPATCH"
|
||||
"PPRINT-EXIT-IF-LIST-EXHAUSTED" "PPRINT-FILL" "PPRINT-INDENT" "PPRINT-LINEAR"
|
||||
"PPRINT-LOGICAL-BLOCK" "PPRINT-NEWLINE" "PPRINT-POP" "PPRINT-TAB" "PPRINT-TABULAR" "PRIN1"
|
||||
"PRIN1-TO-STRING" "PRINC" "PRINC-TO-STRING" "PRINT" "PRINT-NOT-READABLE"
|
||||
"PRINT-NOT-READABLE-OBJECT" "PRINT-OBJECT" "PRINT-UNREADABLE-OBJECT" "PROBE-FILE"
|
||||
"PROCLAIM" "PROG" "PROG*" "PROG1" "PROG2" "PROGN" "PROGRAM-ERROR" "PROGV" "PROVIDE"
|
||||
"PSETF" "PSETQ" "PUSH" "PUSHNEW" "QUOTE" "RANDOM" "RANDOM-STATE" "RANDOM-STATE-P" "RASSOC"
|
||||
"RASSOC-IF" "RASSOC-IF-NOT" "RATIO" "RATIONAL" "RATIONALIZE" "RATIONALP" "READ"
|
||||
"READ-BYTE" "READ-CHAR" "READ-CHAR-NO-HANG" "READ-DELIMITED-LIST" "READ-FROM-STRING"
|
||||
"READ-LINE" "READ-PRESERVING-WHITESPACE" "READ-SEQUENCE" "READER-ERROR" "READTABLE"
|
||||
"READTABLE-CASE" "READTABLEP" "REAL" "REALP" "REALPART" "REDUCE" "REINITIALIZE-INSTANCE"
|
||||
"REM" "REMF" "REMHASH" "REMOVE" "REMOVE-DUPLICATES" "REMOVE-IF" "REMOVE-IF-NOT"
|
||||
"REMOVE-METHOD" "REMPROP" "RENAME-FILE" "RENAME-PACKAGE" "REPLACE" "REQUIRE" "REST"
|
||||
"RESTART" "RESTART-BIND" "RESTART-CASE" "RESTART-NAME" "RETURN" "RETURN-FROM" "REVAPPEND"
|
||||
"REVERSE" "ROOM" "ROTATEF" "ROUND" "ROW-MAJOR-AREF" "RPLACA" "RPLACD" "SAFETY" "SATISFIES"
|
||||
"SBIT" "SCALE-FLOAT" "SCHAR" "SEARCH" "SECOND" "SEQUENCE" "SERIOUS-CONDITION" "SET"
|
||||
"SET-DIFFERENCE" "SET-DISPATCH-MACRO-CHARACTER" "SET-EXCLUSIVE-OR" "SET-MACRO-CHARACTER"
|
||||
"SET-PPRINT-DISPATCH" "SET-SYNTAX-FROM-CHAR" "SETF" "SETQ" "SEVENTH" "SHADOW"
|
||||
"SHADOWING-IMPORT" "SHARED-INITIALIZE" "SHIFTF" "SHORT-FLOAT" "SHORT-FLOAT-EPSILON"
|
||||
"SHORT-FLOAT-NEGATIVE-EPSILON" "SHORT-SITE-NAME" "SIGNAL" "SIGNED-BYTE" "SIGNUM"
|
||||
"SIMPLE-ARRAY" "SIMPLE-BASE-STRING" "SIMPLE-BIT-VECTOR" "SIMPLE-BIT-VECTOR-P"
|
||||
"SIMPLE-CONDITION" "SIMPLE-CONDITION-FORMAT-ARGUMENTS" "SIMPLE-CONDITION-FORMAT-CONTROL"
|
||||
"SIMPLE-ERROR" "SIMPLE-STRING" "SIMPLE-STRING-P" "SIMPLE-TYPE-ERROR" "SIMPLE-VECTOR"
|
||||
"SIMPLE-VECTOR-P" "SIMPLE-WARNING" "SIN" "SINGLE-FLOAT" "SINGLE-FLOAT-EPSILON"
|
||||
"SINGLE-FLOAT-NEGATIVE-EPSILON" "SINH" "SIXTH" "SLEEP" "SLOT-BOUNDP" "SLOT-EXISTS-P"
|
||||
"SLOT-MAKUNBOUND" "SLOT-MISSING" "SLOT-UNBOUND" "SLOT-VALUE" "SOFTWARE-TYPE"
|
||||
"SOFTWARE-VERSION" "SOME" "SORT" "SPACE" "SPECIAL" "SPECIAL-OPERATOR-P" "SPEED" "SQRT"
|
||||
"STABLE-SORT" "STANDARD" "STANDARD-CHAR" "STANDARD-CHAR-P" "STANDARD-CLASS"
|
||||
"STANDARD-GENERIC-FUNCTION" "STANDARD-METHOD" "STANDARD-OBJECT" "STEP" "STORAGE-CONDITION"
|
||||
"STORE-VALUE" "STREAM" "STREAM-ELEMENT-TYPE" "STREAM-ERROR" "STREAM-ERROR-STREAM"
|
||||
"STREAM-EXTERNAL-FORMAT" "STREAMP" "STRING" "STRING-CAPITALIZE" "STRING-DOWNCASE"
|
||||
"STRING-EQUAL" "STRING-GREATERP" "STRING-LEFT-TRIM" "STRING-LESSP" "STRING-NOT-EQUAL"
|
||||
"STRING-NOT-GREATERP" "STRING-NOT-LESSP" "STRING-RIGHT-TRIM" "STRING-STREAM" "STRING-TRIM"
|
||||
"STRING-UPCASE" "STRING/=" "STRING<" "STRING<=" "STRING=" "STRING>" "STRING>=" "STRINGP"
|
||||
"STRUCTURE" "STRUCTURE-CLASS" "STRUCTURE-OBJECT" "STYLE-WARNING" "SUBLIS" "SUBSEQ"
|
||||
"SUBSETP" "SUBST" "SUBST-IF" "SUBST-IF-NOT" "SUBSTITUTE" "SUBSTITUTE-IF"
|
||||
"SUBSTITUTE-IF-NOT" "SUBTYPEP" "SVREF" "SXHASH" "SYMBOL" "SYMBOL-FUNCTION"
|
||||
"SYMBOL-MACROLET" "SYMBOL-NAME" "SYMBOL-PACKAGE" "SYMBOL-PLIST" "SYMBOL-VALUE" "SYMBOLP"
|
||||
"SYNONYM-STREAM" "SYNONYM-STREAM-SYMBOL" "T" "TAGBODY" "TAILP" "TAN" "TANH" "TENTH"
|
||||
"TERPRI" "THE" "THIRD" "THROW" "TIME" "TRACE" "TRANSLATE-LOGICAL-PATHNAME"
|
||||
"TRANSLATE-PATHNAME" "TREE-EQUAL" "TRUENAME" "TRUNCATE" "TWO-WAY-STREAM"
|
||||
"TWO-WAY-STREAM-INPUT-STREAM" "TWO-WAY-STREAM-OUTPUT-STREAM" "TYPE" "TYPE-ERROR"
|
||||
"TYPE-ERROR-DATUM" "TYPE-ERROR-EXPECTED-TYPE" "TYPE-OF" "TYPECASE" "TYPEP" "UNBOUND-SLOT"
|
||||
"UNBOUND-SLOT-INSTANCE" "UNBOUND-VARIABLE" "UNDEFINED-FUNCTION" "UNEXPORT" "UNINTERN"
|
||||
"UNION" "UNLESS" "UNREAD-CHAR" "UNSIGNED-BYTE" "UNTRACE" "UNUSE-PACKAGE" "UNWIND-PROTECT"
|
||||
"UPDATE-INSTANCE-FOR-DIFFERENT-CLASS" "UPDATE-INSTANCE-FOR-REDEFINED-CLASS"
|
||||
"UPGRADED-ARRAY-ELEMENT-TYPE" "UPGRADED-COMPLEX-PART-TYPE" "UPPER-CASE-P" "USE-PACKAGE"
|
||||
"USE-VALUE" "USER-HOMEDIR-PATHNAME" "VALUES" "VALUES-LIST" "VARIABLE" "VECTOR"
|
||||
"VECTOR-POP" "VECTOR-PUSH" "VECTOR-PUSH-EXTEND" "VECTORP" "WARN" "WARNING" "WHEN"
|
||||
"WILD-PATHNAME-P" "WITH-ACCESSORS" "WITH-COMPILATION-UNIT" "WITH-CONDITION-RESTARTS"
|
||||
"WITH-HASH-TABLE-ITERATOR" "WITH-INPUT-FROM-STRING" "WITH-OPEN-FILE" "WITH-OPEN-STREAM"
|
||||
"WITH-OUTPUT-TO-STRING" "WITH-PACKAGE-ITERATOR" "WITH-SIMPLE-RESTART" "WITH-SLOTS"
|
||||
"WITH-STANDARD-IO-SYNTAX" "WRITE" "WRITE-BYTE" "WRITE-CHAR" "WRITE-LINE" "WRITE-SEQUENCE"
|
||||
"WRITE-STRING" "WRITE-TO-STRING" "Y-OR-N-P" "YES-OR-NO-P" "ZEROP"))
|
||||
|
||||
(defvar *export-from-glisp*
|
||||
'(
|
||||
"DEFSUBST"
|
||||
"G/MAKE-STRING"
|
||||
"MP/MAKE-LOCK"
|
||||
"MP/WITH-LOCK"
|
||||
"WITH-TIMEOUT"
|
||||
"OPEN-INET-SOCKET"
|
||||
;; util.lisp :
|
||||
"ALWAYS"
|
||||
"CL-BYTE-STREAM"
|
||||
"CL-CHAR-STREAM"
|
||||
"CL-STREAM"
|
||||
"COMPOSE"
|
||||
"CURRY"
|
||||
"FALSE"
|
||||
"FORCE"
|
||||
"G/CLOSE"
|
||||
"G/FINISH-OUTPUT"
|
||||
"G/PEEK-CHAR"
|
||||
"G/READ-BYTE"
|
||||
"G/READ-BYTE-SEQUENCE"
|
||||
"G/READ-CHAR"
|
||||
"G/READ-CHAR-SEQUENCE"
|
||||
"G/READ-LINE"
|
||||
"G/READ-LINE*"
|
||||
"G/UNREAD-BYTE"
|
||||
"G/UNREAD-CHAR"
|
||||
"G/WRITE-BYTE"
|
||||
"G/WRITE-BYTE-SEQUENCE"
|
||||
"G/WRITE-CHAR"
|
||||
"G/WRITE-STRING"
|
||||
"GSTREAM"
|
||||
"MAP-ARRAY"
|
||||
"MAPFCAR"
|
||||
"MAX*"
|
||||
"MAXF"
|
||||
"MIN*"
|
||||
"MINF"
|
||||
"MULTIPLE-VALUE-OR"
|
||||
"MULTIPLE-VALUE-SOME"
|
||||
"NCONCF"
|
||||
"NEQ"
|
||||
"PROMISE"
|
||||
"RCURRY"
|
||||
"SANIFY-STRING"
|
||||
"SHOW"
|
||||
"SPLIT-BY"
|
||||
"SPLIT-BY-IF"
|
||||
"SPLIT-BY-MEMBER"
|
||||
"SPLIT-STRING"
|
||||
"STRING-BEGIN-EQUAL"
|
||||
"TRUE"
|
||||
"UNTIL"
|
||||
"USE-BYTE-FOR-CHAR-STREAM-FLAVOUR"
|
||||
"USE-CHAR-FOR-BYTE-STREAM-FLAVOUR"
|
||||
"WHILE"
|
||||
"WHITE-SPACE-P"
|
||||
|
||||
"CL-BYTE-STREAM->GSTREAM"
|
||||
"CL-CHAR-STREAM->GSTREAM"
|
||||
"G/OPEN-INET-SOCKET"
|
||||
"ACCEPT-CONNECTION"
|
||||
|
||||
"FIND-TEMPORARY-FILE"
|
||||
"DELETE-TEMPORARY-FILE"
|
||||
"WITH-TEMPORARY-FILE"
|
||||
|
||||
"SET-EQUAL"
|
||||
"MAYBE-PARSE-INTEGER"
|
||||
"NOP"
|
||||
"WITH-STRUCTURE-SLOTS"
|
||||
|
||||
"COMPILE-FUNCALL"
|
||||
"FUNCALL*"
|
||||
"MAPC*"
|
||||
"VREDUCE*"
|
||||
"LREDUCE*"
|
||||
"WITH-UNIQUE-NAMES"
|
||||
|
||||
;; runes.lisp
|
||||
"RUNE"
|
||||
"ROD"
|
||||
"SIMPLE-ROD"
|
||||
"%RUNE"
|
||||
"ROD-CAPITALIZE"
|
||||
"CODE-RUNE"
|
||||
"RUNE-CODE"
|
||||
"RUNE-DOWNCASE"
|
||||
"RUNE-UPCASE"
|
||||
"ROD-DOWNCASE"
|
||||
"ROD-UPCASE"
|
||||
"WHITE-SPACE-RUNE-P"
|
||||
"DIGIT-RUNE-P"
|
||||
"RUNE="
|
||||
"RUNE<="
|
||||
"RUNE>="
|
||||
"RUNE-EQUAL"
|
||||
"RUNEP"
|
||||
"SLOOPY-ROD-P"
|
||||
"ROD="
|
||||
"ROD-EQUAL"
|
||||
"MAKE-ROD"
|
||||
"CHAR-RUNE"
|
||||
"RUNE-CHAR"
|
||||
"ROD-STRING"
|
||||
"STRING-ROD"
|
||||
"ROD-SUBSEQ"
|
||||
|
||||
"G/MAKE-HASH-TABLE"
|
||||
"G/HASHGET"
|
||||
"G/CLRHASH"
|
||||
"STIR-HASH-CODES"
|
||||
"HASH-SEQUENCE"
|
||||
"HASH/STRING-EQUAL"
|
||||
"MAKE-STRING-EQUAL-HASH-TABLE"
|
||||
|
||||
"PRIMEP"
|
||||
|
||||
;; match.lisp
|
||||
"DEFINE-MATCH-MACRO"
|
||||
"IF-MATCH"
|
||||
"GSTREAM-AS-STRING"
|
||||
))
|
||||
|
||||
(defparameter *packages*
|
||||
#-GCL '(:common-lisp)
|
||||
#+GCL '(:lisp :pcl) )
|
||||
|
||||
(defparameter *dep-id*
|
||||
#+CLISP "clisp"
|
||||
#+(AND :CMU (NOT :PTHREAD)) "cmucl"
|
||||
#+(AND :CMU :PTHREAD) "cmucl-dtc"
|
||||
#+(AND ALLEGRO ALLEGRO-V5.0) "acl5"
|
||||
#+(AND ALLEGRO (NOT ALLEGRO-V5.0)) "acl"
|
||||
#+GCL "gcl"
|
||||
#-(OR CLISP CMU ALLEGRO GCL)
|
||||
#.(error "Configure!"))
|
||||
|
||||
;; all symbols, which are defined by gray streams
|
||||
|
||||
(defparameter *gray-symbols*
|
||||
'("FUNDAMENTAL-STREAM"
|
||||
"FUNDAMENTAL-INPUT-STREAM"
|
||||
"FUNDAMENTAL-OUTPUT-STREAM"
|
||||
"FUNDAMENTAL-CHARACTER-STREAM"
|
||||
"FUNDAMENTAL-BINARY-STREAM"
|
||||
"FUNDAMENTAL-CHARACTER-INPUT-STREAM"
|
||||
"FUNDAMENTAL-CHARACTER-OUTPUT-STREAM"
|
||||
"FUNDAMENTAL-BINARY-INPUT-STREAM"
|
||||
|
||||
"STREAM-READ-CHAR"
|
||||
"STREAM-UNREAD-CHAR"
|
||||
"STREAM-READ-CHAR-NO-HANG"
|
||||
"STREAM-PEEK-CHAR"
|
||||
"STREAM-LISTEN"
|
||||
"STREAM-READ-LINE"
|
||||
"STREAM-CLEAR-INPUT"
|
||||
|
||||
"STREAM-WRITE-CHAR"
|
||||
"STREAM-LINE-COLUMN"
|
||||
"STREAM-START-LINE-P"
|
||||
"STREAM-WRITE-STRING"
|
||||
"STREAM-TERPRI"
|
||||
"STREAM-FRESH-LINE"
|
||||
"STREAM-FINISH-OUTPUT"
|
||||
"STREAM-FORCE-OUTPUT"
|
||||
"STREAM-ADVANCE-TO-COLUMN"
|
||||
"STREAM-CLEAR-INPUT"
|
||||
|
||||
"STREAM-READ-BYTE"
|
||||
"STREAM-WRITE-BYTE" ))
|
||||
|
||||
(defparameter *gray-packages*
|
||||
#+:CLISP '(:lisp)
|
||||
#+:CMU '(:ext)
|
||||
#+:ALLEGRO '(:excl)
|
||||
#+:HARLEQUIN-COMMON-LISP '(:stream)
|
||||
)
|
||||
|
||||
(defun seek-symbol (name packages)
|
||||
;; Seek the a symbol named 'name' in `packages'
|
||||
(or (some #'(lambda (p)
|
||||
(multiple-value-bind (sym res) (find-symbol name p)
|
||||
(if (eql res :external)
|
||||
(list sym)
|
||||
nil)))
|
||||
packages)
|
||||
(progn (format T "~&There is no ~A." name)
|
||||
(finish-output)
|
||||
nil)))
|
||||
|
||||
(defun dump-defpackage (sink)
|
||||
(format sink ";; AUTOMATICALLY CREATED -- DO NOT EDIT")
|
||||
(format sink "~%;; Lisp Implementation Type: ~A" (lisp-implementation-type))
|
||||
(format sink "~%;; Lisp Implementation Version: ~A" (lisp-implementation-version))
|
||||
(format sink "~%")
|
||||
(let ((*print-case* :downcase)
|
||||
(export-ansi nil)
|
||||
(export-gray nil))
|
||||
(format sink "~%(in-package :~A)" (package-name *package*))
|
||||
(format sink "~%")
|
||||
(format sink "~%(defpackage :glisp")
|
||||
(format sink "~% (:use)")
|
||||
(labels ((grok (symbols packages)
|
||||
(let ((res nil))
|
||||
(dolist (nam symbols)
|
||||
(let ((sym (seek-symbol nam packages)))
|
||||
(when sym
|
||||
(push (car sym) res)
|
||||
(cond ((multiple-value-bind (sym2 res) (find-symbol nam :glisp)
|
||||
(and sym2 (eq res :external)))
|
||||
(format sink "~% ;; ~S patched" (car sym)) )
|
||||
(t
|
||||
(setf sym (car sym))
|
||||
;; CLISP has no (:import ..) ARG!
|
||||
(format sink "~% (:import-from :~A #:~A)"
|
||||
(package-name (symbol-package sym))
|
||||
(symbol-name sym)))))))
|
||||
res)))
|
||||
(setf export-ansi (grok *all-ansi-symbols* *packages*))
|
||||
(setf export-gray (grok *gray-symbols* *gray-packages*)))
|
||||
(format sink "~%")
|
||||
(format sink "~% ;; -- Export ------------------------------")
|
||||
(format sink "~%")
|
||||
(format sink "~% (:export")
|
||||
(format sink "~% ;; ********** ANSI-CL")
|
||||
(dolist (k (reverse export-ansi))
|
||||
(format sink "~% #:~(~A~)" k))
|
||||
(format sink "~% ;; ********** Gray Streams")
|
||||
(dolist (k (reverse export-gray))
|
||||
(format sink "~% #:~(~A~)" k))
|
||||
(format sink "~%~% ;; ********** Private stuff")
|
||||
(dolist (k *export-from-glisp*)
|
||||
(format sink "~% #:~(~A~)" k))
|
||||
(format sink "))")
|
||||
(format sink "~%")
|
||||
(format sink "~%(defpackage :gluser (:use :glisp))")
|
||||
(format sink "~%") )
|
||||
(terpri sink))
|
||||
|
||||
(defun run ()
|
||||
(make-package :glisp :use ())
|
||||
(load (format nil "dep-~A.lisp" *dep-id*))
|
||||
(with-open-file (sink (format nil "dfpck-~A.lisp" *dep-id*) :direction :output :if-exists :new-version)
|
||||
(dump-defpackage sink)))
|
||||
207
glisp/match.lisp
Normal file
207
glisp/match.lisp
Normal file
@ -0,0 +1,207 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: GLISP; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: Very simple (non-deterministic) regular expression matching
|
||||
;;; Created: 1999-01-21
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: LGPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999 by Gilbert Baumann
|
||||
|
||||
;;; This library is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Library General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 2 of the License, or (at your option) any later version.
|
||||
;;;
|
||||
;;; This library is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Library General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU Library General Public
|
||||
;;; License along with this library; if not, write to the
|
||||
;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;;; Boston, MA 02111-1307 USA.
|
||||
|
||||
(in-package :GLISP)
|
||||
|
||||
;; Syntax
|
||||
;; ------
|
||||
|
||||
;; atom -- match the atom
|
||||
;; (p predicate) -- match, iff (funcall p elt) is non-NIL
|
||||
;; (& a0 .. an) -- match a0a1..an
|
||||
;; (/ a0 .. an) -- match a0 or a1 ... or an
|
||||
;; (* a0 .. an) -- iteration, match any number of (& a0 ... an)
|
||||
;; (+ . rest) == (/ (& . rest) (* . rest))
|
||||
;; (? . rest) == (/ (& . rest) (&))
|
||||
;; (= var subexpr) == assign the subexpr to the match variable 'var'
|
||||
;;
|
||||
;; not implemented:
|
||||
;; (- a b) -- match a, but not b
|
||||
;; (and a b) -- matches if a and b matches
|
||||
;; (or a b) == (/ a b)
|
||||
;; (not x) == matches if x does not match
|
||||
;;
|
||||
|
||||
;; This syntax has to be merged with clex as well.
|
||||
|
||||
(defvar *match-macros* (make-hash-table :test #'eq))
|
||||
|
||||
(defmacro define-match-macro (name args &body body)
|
||||
`(eval-when (compile load eval)
|
||||
(setf (gethash ',name *match-macros*)
|
||||
#'(lambda (whole)
|
||||
(destructuring-bind ,args (cdr whole)
|
||||
,@body)))
|
||||
',name))
|
||||
|
||||
(defun symcat (&rest syms)
|
||||
(let ((pack (dolist (k syms nil)
|
||||
(when (symbolp k)
|
||||
(return (symbol-package k))))))
|
||||
(cond ((null pack)
|
||||
(error "No package for ~S of ~S." 'symcat syms))
|
||||
(t
|
||||
(intern (apply #'concatenate 'string (mapcar #'string syms))
|
||||
pack)))))
|
||||
|
||||
(defun sym-equal (a b)
|
||||
(string= (symbol-name a) (symbol-name b)))
|
||||
|
||||
(defun bau-funcall (fun &rest args)
|
||||
(cond ((and (consp fun) (eq (car fun) 'lambda))
|
||||
(cons fun args))
|
||||
((and (consp fun) (eq (car fun) 'function))
|
||||
(cons (cadr fun) args))
|
||||
(t
|
||||
(list* 'funcall fun args))))
|
||||
|
||||
(defun compile-srx (srx action &key (string-type 'vector) (test '#'eql))
|
||||
(let ((vars nil))
|
||||
(labels ((cmp (x cont-expr)
|
||||
(cond
|
||||
((atom x)
|
||||
(with-unique-names (string start end)
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare (type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
(if (and (< ,start ,end)
|
||||
,(bau-funcall test `(aref ,string ,start) `',x))
|
||||
,(bau-funcall cont-expr string `(the fixnum (1+ ,start)) end)))))
|
||||
|
||||
((sym-equal (car x) 'p)
|
||||
(destructuring-bind (p) (cdr x)
|
||||
(with-unique-names (string start end)
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare (type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
(if (and (< ,start ,end)
|
||||
,(bau-funcall p `(aref ,string ,start)))
|
||||
,(bau-funcall cont-expr string `(the fixnum (1+ ,start)) end))))))
|
||||
|
||||
((sym-equal (car x) '/)
|
||||
(with-unique-names (ccfn string string2 start end end2 j)
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare (type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
(labels ((,ccfn (,string2 ,j ,end2)
|
||||
(declare (type fixnum ,j ,end2)
|
||||
(type ,string-type ,string2))
|
||||
,(bau-funcall cont-expr string2 j end2)))
|
||||
,@(mapcar (lambda (a)
|
||||
`(,(cmp a `#',ccfn) ,string ,start ,end))
|
||||
(cdr x))))))
|
||||
|
||||
((sym-equal (car x) '*)
|
||||
(with-unique-names (ccfn string string2 start end end2 j)
|
||||
(let ((subexpr (cons '& (cdr x))))
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare (type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
(labels ((,ccfn (,string2 ,j ,end2)
|
||||
(declare (type fixnum ,j ,end2)
|
||||
(type ,string-type ,string2))
|
||||
(,(cmp subexpr `#',ccfn) ,string2 ,j ,end2)
|
||||
,(bau-funcall cont-expr string j end)))
|
||||
(,ccfn ,string ,start ,end))))))
|
||||
|
||||
((sym-equal (car x) '&)
|
||||
(case (length x)
|
||||
(1 (with-unique-names (string start end)
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare (type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
,(bau-funcall cont-expr string start end))))
|
||||
(2 (cmp (cadr x) cont-expr))
|
||||
(otherwise
|
||||
(with-unique-names (string start end)
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare (type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
(,(cmp (cadr x)
|
||||
(with-unique-names (string j end)
|
||||
`#'(lambda (,string ,j ,end)
|
||||
(declare (type fixnum ,j ,end)
|
||||
(type ,string-type ,string))
|
||||
(,(cmp (cons '& (cddr x)) cont-expr) ,string ,j ,end))))
|
||||
,string ,start ,end))))))
|
||||
|
||||
((sym-equal (car x) '=)
|
||||
(destructuring-bind (var subexpr) (cdr x)
|
||||
(pushnew var vars)
|
||||
(with-unique-names (string i0 end)
|
||||
`(lambda (,string ,i0 ,end)
|
||||
(declare (type fixnum ,i0 ,end)
|
||||
(type ,string-type ,string))
|
||||
(,(cmp subexpr
|
||||
(with-unique-names (string i1 end)
|
||||
`#'(lambda (,string ,i1 ,end)
|
||||
(declare (type fixnum ,i1 ,end)
|
||||
(type ,string-type ,string))
|
||||
(setf ,(symcat var "-START") ,i0
|
||||
,(symcat var "-END") ,i1)
|
||||
,(bau-funcall cont-expr string i1 end))))
|
||||
,string ,i0 ,end)))))
|
||||
|
||||
((sym-equal (car x) '+)
|
||||
(cmp `(& ,@(cdr x) (* ,@(cdr x))) cont-expr))
|
||||
|
||||
((sym-equal (car x) '?)
|
||||
(cmp `(/ (&) (& ,@(cdr x))) cont-expr))
|
||||
|
||||
(t
|
||||
(let ((mmf (gethash (car x) *match-macros*)))
|
||||
(cond (mmf
|
||||
(cmp (funcall mmf x) cont-expr))
|
||||
(t
|
||||
(error "Unknown symbolic regular expression: ~S." x))))) )))
|
||||
|
||||
(with-unique-names (string start end continuation match)
|
||||
(let ((cf (cmp srx `#',continuation)))
|
||||
`(lambda (,string ,start ,end)
|
||||
(declare ;;#.cl-user:+optimize-very-fast+
|
||||
(type fixnum ,start ,end)
|
||||
(type ,string-type ,string))
|
||||
(block ,match
|
||||
(let ,(mapcan (lambda (var) (list (symcat var "-START") (symcat var "-END"))) vars)
|
||||
(labels (,(with-unique-names (string j end)
|
||||
`(,continuation (,string ,j ,end)
|
||||
(declare (type fixnum ,j ,end)
|
||||
(type ,string-type ,string))
|
||||
(declare (ignore ,string))
|
||||
(if (= ,j ,end)
|
||||
(let ()
|
||||
(return-from ,match ,action))))))
|
||||
(,cf ,string ,start ,end)))
|
||||
nil)))))))
|
||||
|
||||
(defmacro if-match ((string &key start end type (test '#'eql)) srx &body actions)
|
||||
(let ((str (gensym "str")))
|
||||
`(let ((,str ,string))
|
||||
(,(compile-srx srx `(progn .,actions)
|
||||
:string-type (or type 'vector)
|
||||
:test test)
|
||||
,str
|
||||
,(if start start 0)
|
||||
,(if end end `(length ,str))))))
|
||||
|
||||
406
glisp/package.lisp
Normal file
406
glisp/package.lisp
Normal file
@ -0,0 +1,406 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: GLISP-TEMP; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: Generating a sane DEFPACKAGE for GLISP
|
||||
;;; Created: 1999-05-25
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1999,2000 by Gilbert Baumann
|
||||
|
||||
(defpackage :glisp-temp (:use #:cl))
|
||||
(in-package :glisp-temp)
|
||||
|
||||
(defpackage :glisp (:use))
|
||||
|
||||
(eval-when (compile)
|
||||
(defparameter *all-ansi-symbols*
|
||||
'("&ALLOW-OTHER-KEYS" "&AUX" "&BODY" "&ENVIRONMENT" "&KEY" "&OPTIONAL" "&REST" "&WHOLE" "*"
|
||||
"**" "***" "*BREAK-ON-SIGNALS*" "*COMPILE-FILE-PATHNAME*" "*COMPILE-FILE-TRUENAME*"
|
||||
"*COMPILE-PRINT*" "*COMPILE-VERBOSE*" "*DEBUG-IO*" "*DEBUGGER-HOOK*"
|
||||
"*DEFAULT-PATHNAME-DEFAULTS*" "*ERROR-OUTPUT*" "*FEATURES*" "*GENSYM-COUNTER*"
|
||||
"*LOAD-PATHNAME*" "*LOAD-PRINT*" "*LOAD-TRUENAME*" "*LOAD-VERBOSE*" "*MACROEXPAND-HOOK*"
|
||||
"*MODULES*" "*PACKAGE*" "*PRINT-ARRAY*" "*PRINT-BASE*" "*PRINT-CASE*" "*PRINT-CIRCLE*"
|
||||
"*PRINT-ESCAPE*" "*PRINT-GENSYM*" "*PRINT-LENGTH*" "*PRINT-LEVEL*" "*PRINT-LINES*"
|
||||
"*PRINT-MISER-WIDTH*" "*PRINT-PPRINT-DISPATCH*" "*PRINT-PRETTY*" "*PRINT-RADIX*"
|
||||
"*PRINT-READABLY*" "*PRINT-RIGHT-MARGIN*" "*QUERY-IO*" "*RANDOM-STATE*" "*READ-BASE*"
|
||||
"*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*"
|
||||
"*STANDARD-INPUT*" "*STANDARD-OUTPUT*" "*TERMINAL-IO*" "*TRACE-OUTPUT*" "+" "++" "+++" "-"
|
||||
"/" "//" "///" "/=" "1+" "1-" "<" "<=" "=" ">" ">=" "ABORT" "ABS" "ACONS" "ACOS" "ACOSH"
|
||||
"ADD-METHOD" "ADJOIN" "ADJUST-ARRAY" "ADJUSTABLE-ARRAY-P" "ALLOCATE-INSTANCE"
|
||||
"ALPHA-CHAR-P" "ALPHANUMERICP" "AND" "APPEND" "APPLY" "APROPOS" "APROPOS-LIST" "AREF"
|
||||
"ARITHMETIC-ERROR" "ARITHMETIC-ERROR-OPERANDS" "ARITHMETIC-ERROR-OPERATION" "ARRAY"
|
||||
"ARRAY-DIMENSION" "ARRAY-DIMENSION-LIMIT" "ARRAY-DIMENSIONS" "ARRAY-DISPLACEMENT"
|
||||
"ARRAY-ELEMENT-TYPE" "ARRAY-HAS-FILL-POINTER-P" "ARRAY-IN-BOUNDS-P" "ARRAY-RANK"
|
||||
"ARRAY-RANK-LIMIT" "ARRAY-ROW-MAJOR-INDEX" "ARRAY-TOTAL-SIZE" "ARRAY-TOTAL-SIZE-LIMIT"
|
||||
"ARRAYP" "ASH" "ASIN" "ASINH" "ASSERT" "ASSOC" "ASSOC-IF" "ASSOC-IF-NOT" "ATAN" "ATANH"
|
||||
"ATOM" "BASE-CHAR" "BASE-STRING" "BIGNUM" "BIT" "BIT-AND" "BIT-ANDC1" "BIT-ANDC2"
|
||||
"BIT-EQV" "BIT-IOR" "BIT-NAND" "BIT-NOR" "BIT-NOT" "BIT-ORC1" "BIT-ORC2" "BIT-VECTOR"
|
||||
"BIT-VECTOR-P" "BIT-XOR" "BLOCK" "BOOLE" "BOOLE-1" "BOOLE-2" "BOOLE-AND" "BOOLE-ANDC1"
|
||||
"BOOLE-ANDC2" "BOOLE-C1" "BOOLE-C2" "BOOLE-CLR" "BOOLE-EQV" "BOOLE-IOR" "BOOLE-NAND"
|
||||
"BOOLE-NOR" "BOOLE-ORC1" "BOOLE-ORC2" "BOOLE-SET" "BOOLE-XOR" "BOOLEAN" "BOTH-CASE-P"
|
||||
"BOUNDP" "BREAK" "BROADCAST-STREAM" "BROADCAST-STREAM-STREAMS" "BUILT-IN-CLASS" "BUTLAST"
|
||||
"BYTE" "BYTE-POSITION" "BYTE-SIZE" "CAAAAR" "CAAADR" "CAAAR" "CAADAR" "CAADDR" "CAADR"
|
||||
"CAAR" "CADAAR" "CADADR" "CADAR" "CADDAR" "CADDDR" "CADDR" "CADR" "CALL-ARGUMENTS-LIMIT"
|
||||
"CALL-METHOD" "CALL-NEXT-METHOD" "CAR" "CASE" "CATCH" "CCASE" "CDAAAR" "CDAADR" "CDAAR"
|
||||
"CDADAR" "CDADDR" "CDADR" "CDAR" "CDDAAR" "CDDADR" "CDDAR" "CDDDAR" "CDDDDR" "CDDDR"
|
||||
"CDDR" "CDR" "CEILING" "CELL-ERROR" "CELL-ERROR-NAME" "CERROR" "CHANGE-CLASS" "CHAR"
|
||||
"CHAR-CODE" "CHAR-CODE-LIMIT" "CHAR-DOWNCASE" "CHAR-EQUAL" "CHAR-GREATERP" "CHAR-INT"
|
||||
"CHAR-LESSP" "CHAR-NAME" "CHAR-NOT-EQUAL" "CHAR-NOT-GREATERP" "CHAR-NOT-LESSP"
|
||||
"CHAR-UPCASE" "CHAR/=" "CHAR<" "CHAR<=" "CHAR=" "CHAR>" "CHAR>=" "CHARACTER" "CHARACTERP"
|
||||
"CHECK-TYPE" "CIS" "CLASS" "CLASS-NAME" "CLASS-OF" "CLEAR-INPUT" "CLEAR-OUTPUT" "CLOSE"
|
||||
"CLRHASH" "CODE-CHAR" "COERCE" "COMPILATION-SPEED" "COMPILE" "COMPILE-FILE"
|
||||
"COMPILE-FILE-PATHNAME" "COMPILED-FUNCTION" "COMPILED-FUNCTION-P" "COMPILER-MACRO"
|
||||
"COMPILER-MACRO-FUNCTION" "COMPLEMENT" "COMPLEX" "COMPLEXP" "COMPUTE-APPLICABLE-METHODS"
|
||||
"COMPUTE-RESTARTS" "CONCATENATE" "CONCATENATED-STREAM" "CONCATENATED-STREAM-STREAMS"
|
||||
"COND" "CONDITION" "CONJUGATE" "CONS" "CONSP" "CONSTANTLY" "CONSTANTP" "CONTINUE"
|
||||
"CONTROL-ERROR" "COPY-ALIST" "COPY-LIST" "COPY-PPRINT-DISPATCH" "COPY-READTABLE"
|
||||
"COPY-SEQ" "COPY-STRUCTURE" "COPY-SYMBOL" "COPY-TREE" "COS" "COSH" "COUNT" "COUNT-IF"
|
||||
"COUNT-IF-NOT" "CTYPECASE" "DEBUG" "DECF" "DECLAIM" "DECLARATION" "DECLARE" "DECODE-FLOAT"
|
||||
"DECODE-UNIVERSAL-TIME" "DEFCLASS" "DEFCONSTANT" "DEFGENERIC" "DEFINE-COMPILER-MACRO"
|
||||
"DEFINE-CONDITION" "DEFINE-METHOD-COMBINATION" "DEFINE-MODIFY-MACRO"
|
||||
"DEFINE-SETF-EXPANDER" "DEFINE-SYMBOL-MACRO" "DEFMACRO" "DEFMETHOD" "DEFPACKAGE"
|
||||
"DEFPARAMETER" "DEFSETF" "DEFSTRUCT" "DEFTYPE" "DEFUN" "DEFVAR" "DELETE"
|
||||
"DELETE-DUPLICATES" "DELETE-FILE" "DELETE-IF" "DELETE-IF-NOT" "DELETE-PACKAGE"
|
||||
"DENOMINATOR" "DEPOSIT-FIELD" "DESCRIBE" "DESCRIBE-OBJECT" "DESTRUCTURING-BIND"
|
||||
"DIGIT-CHAR" "DIGIT-CHAR-P" "DIRECTORY" "DIRECTORY-NAMESTRING" "DISASSEMBLE"
|
||||
"DIVISION-BY-ZERO" "DO" "DO*" "DO-ALL-SYMBOLS" "DO-EXTERNAL-SYMBOLS" "DO-SYMBOLS"
|
||||
"DOCUMENTATION" "DOLIST" "DOTIMES" "DOUBLE-FLOAT" "DOUBLE-FLOAT-EPSILON"
|
||||
"DOUBLE-FLOAT-NEGATIVE-EPSILON" "DPB" "DRIBBLE" "DYNAMIC-EXTENT" "ECASE" "ECHO-STREAM"
|
||||
"ECHO-STREAM-INPUT-STREAM" "ECHO-STREAM-OUTPUT-STREAM" "ED" "EIGHTH" "ELT"
|
||||
"ENCODE-UNIVERSAL-TIME" "END-OF-FILE" "ENDP" "ENOUGH-NAMESTRING"
|
||||
"ENSURE-DIRECTORIES-EXIST" "ENSURE-GENERIC-FUNCTION" "EQ" "EQL" "EQUAL" "EQUALP" "ERROR"
|
||||
"ETYPECASE" "EVAL" "EVAL-WHEN" "EVENP" "EVERY" "EXP" "EXPORT" "EXPT" "EXTENDED-CHAR"
|
||||
"FBOUNDP" "FCEILING" "FDEFINITION" "FFLOOR" "FIFTH" "FILE-AUTHOR" "FILE-ERROR"
|
||||
"FILE-ERROR-PATHNAME" "FILE-LENGTH" "FILE-NAMESTRING" "FILE-POSITION" "FILE-STREAM"
|
||||
"FILE-STRING-LENGTH" "FILE-WRITE-DATE" "FILL" "FILL-POINTER" "FIND" "FIND-ALL-SYMBOLS"
|
||||
"FIND-CLASS" "FIND-IF" "FIND-IF-NOT" "FIND-METHOD" "FIND-PACKAGE" "FIND-RESTART"
|
||||
"FIND-SYMBOL" "FINISH-OUTPUT" "FIRST" "FIXNUM" "FLET" "FLOAT" "FLOAT-DIGITS"
|
||||
"FLOAT-PRECISION" "FLOAT-RADIX" "FLOAT-SIGN" "FLOATING-POINT-INEXACT"
|
||||
"FLOATING-POINT-INVALID-OPERATION" "FLOATING-POINT-OVERFLOW" "FLOATING-POINT-UNDERFLOW"
|
||||
"FLOATP" "FLOOR" "FMAKUNBOUND" "FORCE-OUTPUT" "FORMAT" "FORMATTER" "FOURTH" "FRESH-LINE"
|
||||
"FROUND" "FTRUNCATE" "FTYPE" "FUNCALL" "FUNCTION" "FUNCTION-KEYWORDS"
|
||||
"FUNCTION-LAMBDA-EXPRESSION" "FUNCTIONP" "GCD" "GENERIC-FUNCTION" "GENSYM" "GENTEMP" "GET"
|
||||
"GET-DECODED-TIME" "GET-DISPATCH-MACRO-CHARACTER" "GET-INTERNAL-REAL-TIME"
|
||||
"GET-INTERNAL-RUN-TIME" "GET-MACRO-CHARACTER" "GET-OUTPUT-STREAM-STRING" "GET-PROPERTIES"
|
||||
"GET-SETF-EXPANSION" "GET-UNIVERSAL-TIME" "GETF" "GETHASH" "GO" "GRAPHIC-CHAR-P"
|
||||
"HANDLER-BIND" "HANDLER-CASE" "HASH-TABLE" "HASH-TABLE-COUNT" "HASH-TABLE-P"
|
||||
"HASH-TABLE-REHASH-SIZE" "HASH-TABLE-REHASH-THRESHOLD" "HASH-TABLE-SIZE" "HASH-TABLE-TEST"
|
||||
"HOST-NAMESTRING" "IDENTITY" "IF" "IGNORABLE" "IGNORE" "IGNORE-ERRORS" "IMAGPART" "IMPORT"
|
||||
"IN-PACKAGE" "INCF" "INITIALIZE-INSTANCE" "INLINE" "INPUT-STREAM-P" "INSPECT" "INTEGER"
|
||||
"INTEGER-DECODE-FLOAT" "INTEGER-LENGTH" "INTEGERP" "INTERACTIVE-STREAM-P" "INTERN"
|
||||
"INTERNAL-TIME-UNITS-PER-SECOND" "INTERSECTION" "INVALID-METHOD-ERROR" "INVOKE-DEBUGGER"
|
||||
"INVOKE-RESTART" "INVOKE-RESTART-INTERACTIVELY" "ISQRT" "KEYWORD" "KEYWORDP" "LABELS"
|
||||
"LAMBDA" "LAMBDA-LIST-KEYWORDS" "LAMBDA-PARAMETERS-LIMIT" "LAST" "LCM" "LDB" "LDB-TEST"
|
||||
"LDIFF" "LEAST-NEGATIVE-DOUBLE-FLOAT" "LEAST-NEGATIVE-LONG-FLOAT"
|
||||
"LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT" "LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT"
|
||||
"LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT" "LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT"
|
||||
"LEAST-NEGATIVE-SHORT-FLOAT" "LEAST-NEGATIVE-SINGLE-FLOAT" "LEAST-POSITIVE-DOUBLE-FLOAT"
|
||||
"LEAST-POSITIVE-LONG-FLOAT" "LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT"
|
||||
"LEAST-POSITIVE-NORMALIZED-LONG-FLOAT" "LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT"
|
||||
"LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT" "LEAST-POSITIVE-SHORT-FLOAT"
|
||||
"LEAST-POSITIVE-SINGLE-FLOAT" "LENGTH" "LET" "LET*" "LISP-IMPLEMENTATION-TYPE"
|
||||
"LISP-IMPLEMENTATION-VERSION" "LIST" "LIST*" "LIST-ALL-PACKAGES" "LIST-LENGTH" "LISTEN"
|
||||
"LISTP" "LOAD" "LOAD-LOGICAL-PATHNAME-TRANSLATIONS" "LOAD-TIME-VALUE" "LOCALLY" "LOG"
|
||||
"LOGAND" "LOGANDC1" "LOGANDC2" "LOGBITP" "LOGCOUNT" "LOGEQV" "LOGICAL-PATHNAME"
|
||||
"LOGICAL-PATHNAME-TRANSLATIONS" "LOGIOR" "LOGNAND" "LOGNOR" "LOGNOT" "LOGORC1" "LOGORC2"
|
||||
"LOGTEST" "LOGXOR" "LONG-FLOAT" "LONG-FLOAT-EPSILON" "LONG-FLOAT-NEGATIVE-EPSILON"
|
||||
"LONG-SITE-NAME" "LOOP" "LOOP-FINISH" "LOWER-CASE-P" "MACHINE-INSTANCE" "MACHINE-TYPE"
|
||||
"MACHINE-VERSION" "MACRO-FUNCTION" "MACROEXPAND" "MACROEXPAND-1" "MACROLET" "MAKE-ARRAY"
|
||||
"MAKE-BROADCAST-STREAM" "MAKE-CONCATENATED-STREAM" "MAKE-CONDITION"
|
||||
"MAKE-DISPATCH-MACRO-CHARACTER" "MAKE-ECHO-STREAM" "MAKE-HASH-TABLE" "MAKE-INSTANCE"
|
||||
"MAKE-INSTANCES-OBSOLETE" "MAKE-LIST" "MAKE-LOAD-FORM" "MAKE-LOAD-FORM-SAVING-SLOTS"
|
||||
"MAKE-METHOD" "MAKE-PACKAGE" "MAKE-PATHNAME" "MAKE-RANDOM-STATE" "MAKE-SEQUENCE"
|
||||
"MAKE-STRING" "MAKE-STRING-INPUT-STREAM" "MAKE-STRING-OUTPUT-STREAM" "MAKE-SYMBOL"
|
||||
"MAKE-SYNONYM-STREAM" "MAKE-TWO-WAY-STREAM" "MAKUNBOUND" "MAP" "MAP-INTO" "MAPC" "MAPCAN"
|
||||
"MAPCAR" "MAPCON" "MAPHASH" "MAPL" "MAPLIST" "MASK-FIELD" "MAX" "MEMBER" "MEMBER-IF"
|
||||
"MEMBER-IF-NOT" "MERGE" "MERGE-PATHNAMES" "METHOD" "METHOD-COMBINATION"
|
||||
"METHOD-COMBINATION-ERROR" "METHOD-QUALIFIERS" "MIN" "MINUSP" "MISMATCH" "MOD"
|
||||
"MOST-NEGATIVE-DOUBLE-FLOAT" "MOST-NEGATIVE-FIXNUM" "MOST-NEGATIVE-LONG-FLOAT"
|
||||
"MOST-NEGATIVE-SHORT-FLOAT" "MOST-NEGATIVE-SINGLE-FLOAT" "MOST-POSITIVE-DOUBLE-FLOAT"
|
||||
"MOST-POSITIVE-FIXNUM" "MOST-POSITIVE-LONG-FLOAT" "MOST-POSITIVE-SHORT-FLOAT"
|
||||
"MOST-POSITIVE-SINGLE-FLOAT" "MUFFLE-WARNING" "MULTIPLE-VALUE-BIND" "MULTIPLE-VALUE-CALL"
|
||||
"MULTIPLE-VALUE-LIST" "MULTIPLE-VALUE-PROG1" "MULTIPLE-VALUE-SETQ" "MULTIPLE-VALUES-LIMIT"
|
||||
"NAME-CHAR" "NAMESTRING" "NBUTLAST" "NCONC" "NEXT-METHOD-P" "NIL" "NINTERSECTION" "NINTH"
|
||||
"NO-APPLICABLE-METHOD" "NO-NEXT-METHOD" "NOT" "NOTANY" "NOTEVERY" "NOTINLINE" "NRECONC"
|
||||
"NREVERSE" "NSET-DIFFERENCE" "NSET-EXCLUSIVE-OR" "NSTRING-CAPITALIZE" "NSTRING-DOWNCASE"
|
||||
"NSTRING-UPCASE" "NSUBLIS" "NSUBST" "NSUBST-IF" "NSUBST-IF-NOT" "NSUBSTITUTE"
|
||||
"NSUBSTITUTE-IF" "NSUBSTITUTE-IF-NOT" "NTH" "NTH-VALUE" "NTHCDR" "NULL" "NUMBER" "NUMBERP"
|
||||
"NUMERATOR" "NUNION" "ODDP" "OPEN" "OPEN-STREAM-P" "OPTIMIZE" "OR" "OTHERWISE"
|
||||
"OUTPUT-STREAM-P" "PACKAGE" "PACKAGE-ERROR" "PACKAGE-ERROR-PACKAGE" "PACKAGE-NAME"
|
||||
"PACKAGE-NICKNAMES" "PACKAGE-SHADOWING-SYMBOLS" "PACKAGE-USE-LIST" "PACKAGE-USED-BY-LIST"
|
||||
"PACKAGEP" "PAIRLIS" "PARSE-ERROR" "PARSE-INTEGER" "PARSE-NAMESTRING" "PATHNAME"
|
||||
"PATHNAME-DEVICE" "PATHNAME-DIRECTORY" "PATHNAME-HOST" "PATHNAME-MATCH-P" "PATHNAME-NAME"
|
||||
"PATHNAME-TYPE" "PATHNAME-VERSION" "PATHNAMEP" "PEEK-CHAR" "PHASE" "PI" "PLUSP" "POP"
|
||||
"POSITION" "POSITION-IF" "POSITION-IF-NOT" "PPRINT" "PPRINT-DISPATCH"
|
||||
"PPRINT-EXIT-IF-LIST-EXHAUSTED" "PPRINT-FILL" "PPRINT-INDENT" "PPRINT-LINEAR"
|
||||
"PPRINT-LOGICAL-BLOCK" "PPRINT-NEWLINE" "PPRINT-POP" "PPRINT-TAB" "PPRINT-TABULAR" "PRIN1"
|
||||
"PRIN1-TO-STRING" "PRINC" "PRINC-TO-STRING" "PRINT" "PRINT-NOT-READABLE"
|
||||
"PRINT-NOT-READABLE-OBJECT" "PRINT-OBJECT" "PRINT-UNREADABLE-OBJECT" "PROBE-FILE"
|
||||
"PROCLAIM" "PROG" "PROG*" "PROG1" "PROG2" "PROGN" "PROGRAM-ERROR" "PROGV" "PROVIDE"
|
||||
"PSETF" "PSETQ" "PUSH" "PUSHNEW" "QUOTE" "RANDOM" "RANDOM-STATE" "RANDOM-STATE-P" "RASSOC"
|
||||
"RASSOC-IF" "RASSOC-IF-NOT" "RATIO" "RATIONAL" "RATIONALIZE" "RATIONALP" "READ"
|
||||
"READ-BYTE" "READ-CHAR" "READ-CHAR-NO-HANG" "READ-DELIMITED-LIST" "READ-FROM-STRING"
|
||||
"READ-LINE" "READ-PRESERVING-WHITESPACE" "READ-SEQUENCE" "READER-ERROR" "READTABLE"
|
||||
"READTABLE-CASE" "READTABLEP" "REAL" "REALP" "REALPART" "REDUCE" "REINITIALIZE-INSTANCE"
|
||||
"REM" "REMF" "REMHASH" "REMOVE" "REMOVE-DUPLICATES" "REMOVE-IF" "REMOVE-IF-NOT"
|
||||
"REMOVE-METHOD" "REMPROP" "RENAME-FILE" "RENAME-PACKAGE" "REPLACE" "REQUIRE" "REST"
|
||||
"RESTART" "RESTART-BIND" "RESTART-CASE" "RESTART-NAME" "RETURN" "RETURN-FROM" "REVAPPEND"
|
||||
"REVERSE" "ROOM" "ROTATEF" "ROUND" "ROW-MAJOR-AREF" "RPLACA" "RPLACD" "SAFETY" "SATISFIES"
|
||||
"SBIT" "SCALE-FLOAT" "SCHAR" "SEARCH" "SECOND" "SEQUENCE" "SERIOUS-CONDITION" "SET"
|
||||
"SET-DIFFERENCE" "SET-DISPATCH-MACRO-CHARACTER" "SET-EXCLUSIVE-OR" "SET-MACRO-CHARACTER"
|
||||
"SET-PPRINT-DISPATCH" "SET-SYNTAX-FROM-CHAR" "SETF" "SETQ" "SEVENTH" "SHADOW"
|
||||
"SHADOWING-IMPORT" "SHARED-INITIALIZE" "SHIFTF" "SHORT-FLOAT" "SHORT-FLOAT-EPSILON"
|
||||
"SHORT-FLOAT-NEGATIVE-EPSILON" "SHORT-SITE-NAME" "SIGNAL" "SIGNED-BYTE" "SIGNUM"
|
||||
"SIMPLE-ARRAY" "SIMPLE-BASE-STRING" "SIMPLE-BIT-VECTOR" "SIMPLE-BIT-VECTOR-P"
|
||||
"SIMPLE-CONDITION" "SIMPLE-CONDITION-FORMAT-ARGUMENTS" "SIMPLE-CONDITION-FORMAT-CONTROL"
|
||||
"SIMPLE-ERROR" "SIMPLE-STRING" "SIMPLE-STRING-P" "SIMPLE-TYPE-ERROR" "SIMPLE-VECTOR"
|
||||
"SIMPLE-VECTOR-P" "SIMPLE-WARNING" "SIN" "SINGLE-FLOAT" "SINGLE-FLOAT-EPSILON"
|
||||
"SINGLE-FLOAT-NEGATIVE-EPSILON" "SINH" "SIXTH" "SLEEP" "SLOT-BOUNDP" "SLOT-EXISTS-P"
|
||||
"SLOT-MAKUNBOUND" "SLOT-MISSING" "SLOT-UNBOUND" "SLOT-VALUE" "SOFTWARE-TYPE"
|
||||
"SOFTWARE-VERSION" "SOME" "SORT" "SPACE" "SPECIAL" "SPECIAL-OPERATOR-P" "SPEED" "SQRT"
|
||||
"STABLE-SORT" "STANDARD" "STANDARD-CHAR" "STANDARD-CHAR-P" "STANDARD-CLASS"
|
||||
"STANDARD-GENERIC-FUNCTION" "STANDARD-METHOD" "STANDARD-OBJECT" "STEP" "STORAGE-CONDITION"
|
||||
"STORE-VALUE" "STREAM" "STREAM-ELEMENT-TYPE" "STREAM-ERROR" "STREAM-ERROR-STREAM"
|
||||
"STREAM-EXTERNAL-FORMAT" "STREAMP" "STRING" "STRING-CAPITALIZE" "STRING-DOWNCASE"
|
||||
"STRING-EQUAL" "STRING-GREATERP" "STRING-LEFT-TRIM" "STRING-LESSP" "STRING-NOT-EQUAL"
|
||||
"STRING-NOT-GREATERP" "STRING-NOT-LESSP" "STRING-RIGHT-TRIM" "STRING-STREAM" "STRING-TRIM"
|
||||
"STRING-UPCASE" "STRING/=" "STRING<" "STRING<=" "STRING=" "STRING>" "STRING>=" "STRINGP"
|
||||
"STRUCTURE" "STRUCTURE-CLASS" "STRUCTURE-OBJECT" "STYLE-WARNING" "SUBLIS" "SUBSEQ"
|
||||
"SUBSETP" "SUBST" "SUBST-IF" "SUBST-IF-NOT" "SUBSTITUTE" "SUBSTITUTE-IF"
|
||||
"SUBSTITUTE-IF-NOT" "SUBTYPEP" "SVREF" "SXHASH" "SYMBOL" "SYMBOL-FUNCTION"
|
||||
"SYMBOL-MACROLET" "SYMBOL-NAME" "SYMBOL-PACKAGE" "SYMBOL-PLIST" "SYMBOL-VALUE" "SYMBOLP"
|
||||
"SYNONYM-STREAM" "SYNONYM-STREAM-SYMBOL" "T" "TAGBODY" "TAILP" "TAN" "TANH" "TENTH"
|
||||
"TERPRI" "THE" "THIRD" "THROW" "TIME" "TRACE" "TRANSLATE-LOGICAL-PATHNAME"
|
||||
"TRANSLATE-PATHNAME" "TREE-EQUAL" "TRUENAME" "TRUNCATE" "TWO-WAY-STREAM"
|
||||
"TWO-WAY-STREAM-INPUT-STREAM" "TWO-WAY-STREAM-OUTPUT-STREAM" "TYPE" "TYPE-ERROR"
|
||||
"TYPE-ERROR-DATUM" "TYPE-ERROR-EXPECTED-TYPE" "TYPE-OF" "TYPECASE" "TYPEP" "UNBOUND-SLOT"
|
||||
"UNBOUND-SLOT-INSTANCE" "UNBOUND-VARIABLE" "UNDEFINED-FUNCTION" "UNEXPORT" "UNINTERN"
|
||||
"UNION" "UNLESS" "UNREAD-CHAR" "UNSIGNED-BYTE" "UNTRACE" "UNUSE-PACKAGE" "UNWIND-PROTECT"
|
||||
"UPDATE-INSTANCE-FOR-DIFFERENT-CLASS" "UPDATE-INSTANCE-FOR-REDEFINED-CLASS"
|
||||
"UPGRADED-ARRAY-ELEMENT-TYPE" "UPGRADED-COMPLEX-PART-TYPE" "UPPER-CASE-P" "USE-PACKAGE"
|
||||
"USE-VALUE" "USER-HOMEDIR-PATHNAME" "VALUES" "VALUES-LIST" "VARIABLE" "VECTOR"
|
||||
"VECTOR-POP" "VECTOR-PUSH" "VECTOR-PUSH-EXTEND" "VECTORP" "WARN" "WARNING" "WHEN"
|
||||
"WILD-PATHNAME-P" "WITH-ACCESSORS" "WITH-COMPILATION-UNIT" "WITH-CONDITION-RESTARTS"
|
||||
"WITH-HASH-TABLE-ITERATOR" "WITH-INPUT-FROM-STRING" "WITH-OPEN-FILE" "WITH-OPEN-STREAM"
|
||||
"WITH-OUTPUT-TO-STRING" "WITH-PACKAGE-ITERATOR" "WITH-SIMPLE-RESTART" "WITH-SLOTS"
|
||||
"WITH-STANDARD-IO-SYNTAX" "WRITE" "WRITE-BYTE" "WRITE-CHAR" "WRITE-LINE" "WRITE-SEQUENCE"
|
||||
"WRITE-STRING" "WRITE-TO-STRING" "Y-OR-N-P" "YES-OR-NO-P" "ZEROP"))
|
||||
|
||||
(defvar *export-from-glisp*
|
||||
'(
|
||||
"DEFSUBST"
|
||||
"G/MAKE-STRING"
|
||||
"MP/MAKE-LOCK"
|
||||
"MP/WITH-LOCK"
|
||||
"WITH-TIMEOUT"
|
||||
"OPEN-INET-SOCKET"
|
||||
;; util.lisp :
|
||||
"ALWAYS"
|
||||
"CL-BYTE-STREAM"
|
||||
"CL-CHAR-STREAM"
|
||||
"CL-STREAM"
|
||||
"COMPOSE"
|
||||
"CURRY"
|
||||
"FALSE"
|
||||
"FORCE"
|
||||
"G/CLOSE"
|
||||
"G/FINISH-OUTPUT"
|
||||
"G/PEEK-CHAR"
|
||||
"G/READ-BYTE"
|
||||
"G/READ-BYTE-SEQUENCE"
|
||||
"G/READ-CHAR"
|
||||
"G/READ-CHAR-SEQUENCE"
|
||||
"G/READ-LINE"
|
||||
"G/READ-LINE*"
|
||||
"G/UNREAD-BYTE"
|
||||
"G/UNREAD-CHAR"
|
||||
"G/WRITE-BYTE"
|
||||
"G/WRITE-BYTE-SEQUENCE"
|
||||
"G/WRITE-CHAR"
|
||||
"G/WRITE-STRING"
|
||||
"GSTREAM"
|
||||
"MAP-ARRAY"
|
||||
"MAPFCAR"
|
||||
"MAX*"
|
||||
"MAXF"
|
||||
"MIN*"
|
||||
"MINF"
|
||||
"MULTIPLE-VALUE-OR"
|
||||
"MULTIPLE-VALUE-SOME"
|
||||
"NCONCF"
|
||||
"NEQ"
|
||||
"PROMISE"
|
||||
"RCURRY"
|
||||
"SANIFY-STRING"
|
||||
"SHOW"
|
||||
"SPLIT-BY"
|
||||
"SPLIT-BY-IF"
|
||||
"SPLIT-BY-MEMBER"
|
||||
"SPLIT-STRING"
|
||||
"STRING-BEGIN-EQUAL"
|
||||
"TRUE"
|
||||
"UNTIL"
|
||||
"USE-BYTE-FOR-CHAR-STREAM-FLAVOUR"
|
||||
"USE-CHAR-FOR-BYTE-STREAM-FLAVOUR"
|
||||
"WHILE"
|
||||
"WHITE-SPACE-P"
|
||||
|
||||
"CL-BYTE-STREAM->GSTREAM"
|
||||
"CL-CHAR-STREAM->GSTREAM"
|
||||
"G/OPEN-INET-SOCKET"
|
||||
"ACCEPT-CONNECTION"
|
||||
|
||||
"FIND-TEMPORARY-FILE"
|
||||
"DELETE-TEMPORARY-FILE"
|
||||
"WITH-TEMPORARY-FILE"
|
||||
|
||||
"SET-EQUAL"
|
||||
"MAYBE-PARSE-INTEGER"
|
||||
"NOP"
|
||||
"WITH-STRUCTURE-SLOTS"
|
||||
|
||||
"COMPILE-FUNCALL"
|
||||
"FUNCALL*"
|
||||
"MAPC*"
|
||||
"VREDUCE*"
|
||||
"LREDUCE*"
|
||||
"WITH-UNIQUE-NAMES"
|
||||
|
||||
;; runes.lisp
|
||||
"RUNE"
|
||||
"ROD"
|
||||
"SIMPLE-ROD"
|
||||
"%RUNE"
|
||||
"ROD-CAPITALIZE"
|
||||
"CODE-RUNE"
|
||||
"RUNE-CODE"
|
||||
"RUNE-DOWNCASE"
|
||||
"RUNE-UPCASE"
|
||||
"ROD-DOWNCASE"
|
||||
"ROD-UPCASE"
|
||||
"WHITE-SPACE-RUNE-P"
|
||||
"DIGIT-RUNE-P"
|
||||
"RUNE="
|
||||
"RUNE<="
|
||||
"RUNE>="
|
||||
"RUNE-EQUAL"
|
||||
"RUNEP"
|
||||
"SLOOPY-ROD-P"
|
||||
"ROD="
|
||||
"ROD-EQUAL"
|
||||
"MAKE-ROD"
|
||||
"CHAR-RUNE"
|
||||
"RUNE-CHAR"
|
||||
"ROD-STRING"
|
||||
"STRING-ROD"
|
||||
"ROD-SUBSEQ"
|
||||
|
||||
"G/MAKE-HASH-TABLE"
|
||||
"G/HASHGET"
|
||||
"G/CLRHASH"
|
||||
"STIR-HASH-CODES"
|
||||
"HASH-SEQUENCE"
|
||||
"HASH/STRING-EQUAL"
|
||||
"MAKE-STRING-EQUAL-HASH-TABLE"
|
||||
|
||||
"PRIMEP"
|
||||
|
||||
;; match.lisp
|
||||
"DEFINE-MATCH-MACRO"
|
||||
"IF-MATCH"
|
||||
"GSTREAM-AS-STRING"
|
||||
))
|
||||
|
||||
(defparameter *packages*
|
||||
#-GCL '(:common-lisp)
|
||||
#+GCL '(:lisp :pcl) )
|
||||
|
||||
(defparameter *gray-symbols*
|
||||
'("FUNDAMENTAL-STREAM"
|
||||
"FUNDAMENTAL-INPUT-STREAM"
|
||||
"FUNDAMENTAL-OUTPUT-STREAM"
|
||||
"FUNDAMENTAL-CHARACTER-STREAM"
|
||||
"FUNDAMENTAL-BINARY-STREAM"
|
||||
"FUNDAMENTAL-CHARACTER-INPUT-STREAM"
|
||||
"FUNDAMENTAL-CHARACTER-OUTPUT-STREAM"
|
||||
"FUNDAMENTAL-BINARY-INPUT-STREAM"
|
||||
|
||||
"STREAM-READ-CHAR"
|
||||
"STREAM-UNREAD-CHAR"
|
||||
"STREAM-READ-CHAR-NO-HANG"
|
||||
"STREAM-PEEK-CHAR"
|
||||
"STREAM-LISTEN"
|
||||
"STREAM-READ-LINE"
|
||||
"STREAM-CLEAR-INPUT"
|
||||
|
||||
"STREAM-WRITE-CHAR"
|
||||
"STREAM-LINE-COLUMN"
|
||||
"STREAM-START-LINE-P"
|
||||
"STREAM-WRITE-STRING"
|
||||
"STREAM-TERPRI"
|
||||
"STREAM-FRESH-LINE"
|
||||
"STREAM-FINISH-OUTPUT"
|
||||
"STREAM-FORCE-OUTPUT"
|
||||
"STREAM-ADVANCE-TO-COLUMN"
|
||||
|
||||
"STREAM-READ-BYTE"
|
||||
"STREAM-WRITE-BYTE" ))
|
||||
|
||||
(defparameter *gray-packages*
|
||||
`(
|
||||
#+:CLISP ,@'(:lisp)
|
||||
#+:CMU ,@'(:ext)
|
||||
#+:sbcl ,@'(:sb-gray)
|
||||
#+:ALLEGRO ,@'(:common-lisp :excl :stream)
|
||||
#+:HARLEQUIN-COMMON-LISP ,@'(:stream)
|
||||
#+:OPENMCL ,@'(:ccl)
|
||||
))
|
||||
|
||||
(defun seek-symbol (name packages)
|
||||
;; Seek the a symbol named 'name' in `packages'
|
||||
(or (some #'(lambda (p)
|
||||
(multiple-value-bind (sym res) (find-symbol name p)
|
||||
(if (eql res :external)
|
||||
(list sym)
|
||||
nil)))
|
||||
packages)
|
||||
(progn (format T "~&There is no ~A in ~A." name packages)
|
||||
(finish-output)
|
||||
nil)))
|
||||
|
||||
(defun dump-defpackage (&aux imports export-ansi export-gray)
|
||||
(labels ((grok (symbols packages)
|
||||
(let ((res nil))
|
||||
(dolist (nam symbols)
|
||||
(let ((sym (seek-symbol nam packages)))
|
||||
(when sym
|
||||
(push (car sym) res)
|
||||
(cond ((multiple-value-bind (sym2 res) (find-symbol nam :glisp)
|
||||
(and sym2 (eq res :external)))
|
||||
;;
|
||||
(format T "~&;; ~S is pacthed." sym) )
|
||||
(t
|
||||
(setf sym (car sym))
|
||||
;; CLISP has no (:import ..) ARG!
|
||||
(push `(:import-from
|
||||
,(package-name (symbol-package sym))
|
||||
,(symbol-name sym))
|
||||
imports))))))
|
||||
res)))
|
||||
(setf export-ansi (grok *all-ansi-symbols* *packages*))
|
||||
(setf export-gray (grok *gray-symbols* *gray-packages*))
|
||||
`(progn
|
||||
(defpackage "GLISP" (:use)
|
||||
,@imports
|
||||
(:export
|
||||
,@(mapcar #'symbol-name export-ansi)
|
||||
,@(mapcar #'symbol-name export-gray)
|
||||
,@*export-from-glisp*))
|
||||
(defpackage "GLUSER"
|
||||
(:use "GLISP")) )))
|
||||
|
||||
(defmacro define-glisp-package ()
|
||||
(dump-defpackage))
|
||||
)
|
||||
|
||||
(define-glisp-package)
|
||||
|
||||
412
glisp/runes.lisp
Normal file
412
glisp/runes.lisp
Normal file
@ -0,0 +1,412 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: GLISP; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: Unicode strings (called RODs)
|
||||
;;; Created: 1999-05-25 22:29
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1998,1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
;; Changes
|
||||
;;
|
||||
;; When Who What
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; 1999-08-15 GB - ROD=, ROD-EQUAL
|
||||
;; RUNE<=, RUNE>=
|
||||
;; MAKE-ROD, ROD-SUBSEQ
|
||||
;; CHAR-RUNE, RUNE-CHAR, ROD-STRING, STRING-ROD
|
||||
;; new functions
|
||||
;; - Added rune reader
|
||||
;;
|
||||
|
||||
(in-package :GLISP)
|
||||
|
||||
(deftype rune () '(unsigned-byte 16))
|
||||
(deftype rod () '(array rune (*)))
|
||||
(deftype simple-rod () '(simple-array rune (*)))
|
||||
|
||||
(defsubst rune (rod index)
|
||||
(aref rod index))
|
||||
|
||||
(defun (setf rune) (new rod index)
|
||||
(setf (aref rod index) new))
|
||||
|
||||
(defsubst %rune (rod index)
|
||||
(aref (the (simple-array (unsigned-byte 16) (*)) rod) (the fixnum index)))
|
||||
|
||||
(defsubst (setf %rune) (new rod index)
|
||||
(setf (aref (the (simple-array (unsigned-byte 16) (*)) rod) (the fixnum index)) new))
|
||||
|
||||
(defun rod-capitalize (rod)
|
||||
(warn "~S is not implemented." 'rod-capitalize)
|
||||
rod)
|
||||
|
||||
(defsubst code-rune (x) x)
|
||||
(defsubst rune-code (x) x)
|
||||
|
||||
(defsubst rune= (x y)
|
||||
(= x y))
|
||||
|
||||
(defun rune-downcase (rune)
|
||||
(cond ((<= #x0041 rune #x005a) (+ rune #x20))
|
||||
((= rune #x00d7) rune)
|
||||
((<= #x00c0 rune #x00de) (+ rune #x20))
|
||||
(t rune)))
|
||||
|
||||
(defsubst rune-upcase (rune)
|
||||
(cond ((<= #x0061 rune #x007a) (- rune #x20))
|
||||
((= rune #x00f7) rune)
|
||||
((<= #x00e0 rune #x00fe) (- rune #x20))
|
||||
(t rune)))
|
||||
|
||||
(defun rune-upper-case-letter-p (rune)
|
||||
(or (<= #x0041 rune #x005a) (<= #x00c0 rune #x00de)))
|
||||
|
||||
(defun rune-lower-case-letter-p (rune)
|
||||
(or (<= #x0061 rune #x007a) (<= #x00e0 rune #x00fe)
|
||||
(= rune #x00d7)))
|
||||
|
||||
|
||||
(defun rune-equal (x y)
|
||||
(rune= (rune-upcase x) (rune-upcase y)))
|
||||
|
||||
(defun rod-downcase (rod)
|
||||
;; FIXME
|
||||
(register-rod
|
||||
(map '(simple-array (unsigned-byte 16) (*)) #'rune-downcase rod)))
|
||||
|
||||
(defun rod-upcase (rod)
|
||||
;; FIXME
|
||||
(register-rod
|
||||
(map '(simple-array (unsigned-byte 16) (*)) #'rune-upcase rod)))
|
||||
|
||||
(defsubst white-space-rune-p (char)
|
||||
(or (= char 9) ;TAB
|
||||
(= char 10) ;Linefeed
|
||||
(= char 13) ;Carriage Return
|
||||
(= char 32))) ;Space
|
||||
|
||||
(defsubst digit-rune-p (char &optional (radix 10))
|
||||
(cond ((<= #.(char-code #\0) char #.(char-code #\9))
|
||||
(and (< (- char #.(char-code #\0)) radix)
|
||||
(- char #.(char-code #\0))))
|
||||
((<= #.(char-code #\A) char #.(char-code #\Z))
|
||||
(and (< (- char #.(char-code #\A) -10) radix)
|
||||
(- char #.(char-code #\A) -10)))
|
||||
((<= #.(char-code #\a) char #.(char-code #\z))
|
||||
(and (< (- char #.(char-code #\a) -10) radix)
|
||||
(- char #.(char-code #\a) -10))) ))
|
||||
|
||||
(defun rod (x)
|
||||
(cond ((stringp x) (register-rod (map 'rod #'char-code x)))
|
||||
((symbolp x) (rod (string x)))
|
||||
((characterp x) (rod (string x)))
|
||||
((vectorp x) (register-rod (coerce x 'rod)))
|
||||
((integerp x) (register-rod (map 'rod #'identity (list x))))
|
||||
(t (error "Cannot convert ~S to a ~S" x 'rod))))
|
||||
|
||||
(defun runep (x)
|
||||
(and (integerp x)
|
||||
(<= 0 x #xFFFF)))
|
||||
|
||||
(defun sloopy-rod-p (x)
|
||||
(and (not (stringp x))
|
||||
(vectorp x)
|
||||
(every #'runep x)))
|
||||
|
||||
(defun rod= (x y)
|
||||
(and (= (length x) (length y))
|
||||
(dotimes (i (length x) t)
|
||||
(unless (rune= (rune x i) (rune y i))
|
||||
(return nil)))))
|
||||
|
||||
(defun rod-equal (x y)
|
||||
(and (= (length x) (length y))
|
||||
(dotimes (i (length x) t)
|
||||
(unless (rune-equal (rune x i) (rune y i))
|
||||
(return nil)))))
|
||||
|
||||
(defsubst make-rod (size)
|
||||
(let ((res (make-array size :element-type 'rune)))
|
||||
(register-rod res)
|
||||
res))
|
||||
|
||||
(defun char-rune (char)
|
||||
(code-rune (char-code char)))
|
||||
|
||||
(defun rune-char (rune &optional (default #\?))
|
||||
#+CMU
|
||||
(if (< rune 256) (code-char rune) default)
|
||||
#-CMU
|
||||
(or (code-char rune) default))
|
||||
|
||||
(defun rod-string (rod &optional (default-char #\?))
|
||||
(map 'string (lambda (x) (rune-char x default-char)) rod))
|
||||
|
||||
(defun string-rod (string)
|
||||
(let* ((n (length string))
|
||||
(res (make-rod n)))
|
||||
(dotimes (i n)
|
||||
(setf (%rune res i) (char-rune (char string i))))
|
||||
res))
|
||||
|
||||
;;;;
|
||||
;;;; RUNE Reader
|
||||
;;;;
|
||||
|
||||
;; Portable implementation of WHITE-SPACE-P with regard to the current
|
||||
;; read table -- this is bit tricky.
|
||||
|
||||
(defun rt-white-space-p (char)
|
||||
(let ((stream (make-string-input-stream (string char))))
|
||||
(eq :eof (peek-char t stream nil :eof))))
|
||||
|
||||
(defun read-rune-name (input)
|
||||
;; the first char is unconditionally read
|
||||
(let ((char0 (read-char input t nil t)))
|
||||
(when (char= char0 #\\)
|
||||
(setf char0 (read-char input t nil t)))
|
||||
(with-output-to-string (res)
|
||||
(write-char char0 res)
|
||||
(do ((ch (peek-char nil input nil :eof t) (peek-char nil input nil :eof t)))
|
||||
((or (eq ch :eof)
|
||||
(rt-white-space-p ch)
|
||||
(multiple-value-bind (function non-terminating-p) (get-macro-character ch)
|
||||
(and function (not non-terminating-p)))))
|
||||
(write-char ch res)
|
||||
(read-char input))))) ;consume this character
|
||||
|
||||
(defun iso-10646-char-code (char)
|
||||
(char-code char))
|
||||
|
||||
(defvar *rune-names* (make-hash-table :test #'equal)
|
||||
"Hashtable, which maps all known rune names to rune codes;
|
||||
Names are stored in uppercase.")
|
||||
|
||||
(defun define-rune-name (name code)
|
||||
(setf (gethash (string-upcase name) *rune-names*) code)
|
||||
name)
|
||||
|
||||
(defun lookup-rune-name (name)
|
||||
(gethash (string-upcase name) *rune-names*))
|
||||
|
||||
(define-rune-name "null" #x0000)
|
||||
(define-rune-name "space" #x0020)
|
||||
(define-rune-name "newline" #x000A)
|
||||
(define-rune-name "return" #x000D)
|
||||
(define-rune-name "tab" #x0009)
|
||||
(define-rune-name "page" #x000C)
|
||||
|
||||
;; and just for fun:
|
||||
(define-rune-name "euro" #x20AC)
|
||||
|
||||
;; ASCII control characters
|
||||
(define-rune-name "nul" #x0000) ;null
|
||||
(define-rune-name "soh" #x0001) ;start of header
|
||||
(define-rune-name "stx" #x0002) ;start of text
|
||||
(define-rune-name "etx" #x0003) ;end of text
|
||||
(define-rune-name "eot" #x0004) ;end of transmission
|
||||
(define-rune-name "enq" #x0005) ;
|
||||
(define-rune-name "ack" #x0006) ;acknowledge
|
||||
(define-rune-name "bel" #x0007) ;bell
|
||||
(define-rune-name "bs" #x0008) ;backspace
|
||||
(define-rune-name "ht" #x0009) ;horizontal tab
|
||||
(define-rune-name "lf" #X000A) ;line feed, new line
|
||||
(define-rune-name "vt" #X000B) ;vertical tab
|
||||
(define-rune-name "ff" #x000C) ;form feed
|
||||
(define-rune-name "cr" #x000D) ;carriage return
|
||||
(define-rune-name "so" #x000E) ;shift out
|
||||
(define-rune-name "si" #x000F) ;shift in
|
||||
(define-rune-name "dle" #x0010) ;device latch enable ?
|
||||
(define-rune-name "dc1" #x0011) ;device control 1
|
||||
(define-rune-name "dc2" #x0012) ;device control 2
|
||||
(define-rune-name "dc3" #x0013) ;device control 3
|
||||
(define-rune-name "dc4" #x0014) ;device control 4
|
||||
(define-rune-name "nak" #x0015) ;negative acknowledge
|
||||
(define-rune-name "syn" #x0016) ;
|
||||
(define-rune-name "etb" #x0017) ;
|
||||
(define-rune-name "can" #x0018) ;
|
||||
(define-rune-name "em" #x0019) ;end of message
|
||||
(define-rune-name "sub" #x001A) ;
|
||||
(define-rune-name "esc" #x001B) ;escape
|
||||
(define-rune-name "fs" #x001C) ;field separator ?
|
||||
(define-rune-name "gs" #x001D) ;group separator
|
||||
(define-rune-name "rs" #x001E) ;
|
||||
(define-rune-name "us" #x001F) ;
|
||||
|
||||
(define-rune-name "del" #x007F) ;delete
|
||||
|
||||
;; iso-latin
|
||||
(define-rune-name "nbsp" #x00A0) ;non breakable space
|
||||
(define-rune-name "shy" #x00AD) ;soft hyphen
|
||||
|
||||
(defun rune-from-read-name (name)
|
||||
(cond ((= (length name) 1)
|
||||
(iso-10646-char-code (char name 0)))
|
||||
((and (= (length name) 2)
|
||||
(char= (char name 0) #\\))
|
||||
(iso-10646-char-code (char name 1)))
|
||||
((and (>= (length name) 3)
|
||||
(char-equal (char name 0) #\u)
|
||||
(char-equal (char name 1) #\+)
|
||||
(every (lambda (x) (digit-char-p x 16)) (subseq name 2)))
|
||||
(parse-integer name :start 2 :radix 16))
|
||||
((lookup-rune-name name))
|
||||
(t
|
||||
(error "Meaningless rune name ~S." name))))
|
||||
|
||||
(defun rune-reader (stream subchar arg)
|
||||
subchar arg
|
||||
(values (rune-from-read-name (read-rune-name stream))))
|
||||
|
||||
(set-dispatch-macro-character #\# #\/ 'rune-reader)
|
||||
|
||||
;;;;
|
||||
|
||||
(defun rune<= (rune &rest more-runes)
|
||||
(apply #'<= rune more-runes))
|
||||
|
||||
(defun rune>= (rune &rest more-runes)
|
||||
(apply #'>= rune more-runes))
|
||||
|
||||
(defun rodp (object)
|
||||
(typep object 'rod))
|
||||
|
||||
(defun really-rod-p (object)
|
||||
(and (typep object 'rod)
|
||||
(really-really-rod-p object)))
|
||||
|
||||
(defun rod-subseq (source start &optional (end (length source)))
|
||||
(unless (rodp source)
|
||||
(error "~S is not of type ~S." source 'rod))
|
||||
(unless (and (typep start 'fixnum) (>= start 0))
|
||||
(error "~S is not a non-negative fixnum." start))
|
||||
(unless (and (typep end 'fixnum) (>= end start))
|
||||
(error "END argument, ~S, is not a fixnum no less than START, ~S." end start))
|
||||
(when (> start (length source))
|
||||
(error "START argument, ~S, should be no greater than length of rod." start))
|
||||
(when (> end (length source))
|
||||
(error "END argument, ~S, should be no greater than length of rod." end))
|
||||
(locally
|
||||
(declare (type rod source)
|
||||
(type fixnum start end))
|
||||
(let ((res (make-rod (- end start))))
|
||||
(declare (type rod res))
|
||||
(do ((i (- (- end start) 1) (the fixnum (- i 1))))
|
||||
((< i 0) res)
|
||||
(declare (type fixnum i))
|
||||
(setf (%rune res i) (%rune source (the fixnum (+ i start))))))))
|
||||
|
||||
(defun rod-subseq* (source start &optional (end (length source)))
|
||||
(unless (and (typep start 'fixnum) (>= start 0))
|
||||
(error "~S is not a non-negative fixnum." start))
|
||||
(unless (and (typep end 'fixnum) (>= end start))
|
||||
(error "END argument, ~S, is not a fixnum no less than START, ~S." end start))
|
||||
(when (> start (length source))
|
||||
(error "START argument, ~S, should be no greater than length of rod." start))
|
||||
(when (> end (length source))
|
||||
(error "END argument, ~S, should be no greater than length of rod." end))
|
||||
(locally
|
||||
(declare (type fixnum start end))
|
||||
(let ((res (make-rod (- end start))))
|
||||
(declare (type rod res))
|
||||
(do ((i (- (- end start) 1) (the fixnum (- i 1))))
|
||||
((< i 0) res)
|
||||
(declare (type fixnum i))
|
||||
(setf (%rune res i) (aref source (the fixnum (+ i start))))))))
|
||||
|
||||
;;; Support for telling ROD and arrays apart:
|
||||
|
||||
#+CMU
|
||||
(progn
|
||||
(defvar *rod-hash-table*
|
||||
(make-array 5003 :initial-element nil)))
|
||||
|
||||
(defun register-rod (rod)
|
||||
#+CMU
|
||||
(unless (really-really-rod-p rod)
|
||||
(push (ext:make-weak-pointer rod)
|
||||
(aref *rod-hash-table* (mod (cl::pointer-hash rod)
|
||||
(length *rod-hash-table*)))))
|
||||
rod)
|
||||
|
||||
(defun really-really-rod-p (rod)
|
||||
#+CMU
|
||||
(find rod (aref *rod-hash-table* (mod (cl::pointer-hash rod)
|
||||
(length *rod-hash-table*)))
|
||||
:key #'ext:weak-pointer-value))
|
||||
|
||||
#+CMU
|
||||
(progn
|
||||
(defun rod-hash-table-rehash ()
|
||||
(let* ((n 5003)
|
||||
(new (make-array n :initial-element nil)))
|
||||
(loop for bucket across *rod-hash-table* do
|
||||
(loop for item in bucket do
|
||||
(let ((v (ext:weak-pointer-value item)))
|
||||
(when v
|
||||
(push item (aref new (mod (cl::pointer-hash v) n)))))))
|
||||
(setf *rod-hash-table* new)))
|
||||
|
||||
(defun rod-hash-after-gc-hook ()
|
||||
;; hmm interesting question: should we rehash?
|
||||
(rod-hash-table-rehash))
|
||||
|
||||
(pushnew 'rod-hash-after-gc-hook extensions:*after-gc-hooks*) )
|
||||
|
||||
;;; ROD ext syntax
|
||||
|
||||
(defun rod-reader (stream subchar arg)
|
||||
(declare (ignore arg))
|
||||
(rod
|
||||
(with-output-to-string (bag)
|
||||
(do ((c (read-char stream t nil t)
|
||||
(read-char stream t nil t)))
|
||||
((char= c subchar))
|
||||
(cond ((char= c #\\)
|
||||
(setf c (read-char stream t nil t))))
|
||||
(princ c bag)))))
|
||||
|
||||
(defun rod-printer (stream rod)
|
||||
(princ #\# stream)
|
||||
(princ #\" stream)
|
||||
(loop for x across rod do
|
||||
(cond ((or (rune= x #.(char-code #\\))
|
||||
(rune= x #.(char-code #\")))
|
||||
(princ #\\ stream)
|
||||
(princ (code-char x) stream))
|
||||
((< x char-code-limit)
|
||||
(princ (code-char x) stream))
|
||||
(t
|
||||
(format stream "\\u~4,'0X" x))))
|
||||
(princ #\" stream))
|
||||
|
||||
(set-pprint-dispatch '(satisfies really-rod-p) #'rod-printer)
|
||||
|
||||
(set-dispatch-macro-character #\# #\" 'rod-reader)
|
||||
|
||||
#||
|
||||
(defun longish-array-p (arr)
|
||||
(and (arrayp arr)
|
||||
(> (array-total-size arr) 10)))
|
||||
|
||||
(set-pprint-dispatch '(satisfies longish-array-p)
|
||||
#'(lambda (stream object)
|
||||
(let ((*print-array* nil)
|
||||
(*print-pretty* nil))
|
||||
(prin1 object stream))))
|
||||
||#
|
||||
190
glisp/syntax.lisp
Normal file
190
glisp/syntax.lisp
Normal file
@ -0,0 +1,190 @@
|
||||
;;; -*- Mode: Lisp; Syntax: Common-Lisp; Package: GLISP; -*-
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; Title: Unicode strings (called RODs)
|
||||
;;; Created: 1999-05-25 22:29
|
||||
;;; Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
|
||||
;;; License: GPL (See file COPYING for details).
|
||||
;;; ---------------------------------------------------------------------------
|
||||
;;; (c) copyright 1998,1999 by Gilbert Baumann
|
||||
|
||||
;;; This program is free software; you can redistribute it and/or modify
|
||||
;;; it under the terms of the GNU General Public License as published by
|
||||
;;; the Free Software Foundation; either version 2 of the License, or
|
||||
;;; (at your option) any later version.
|
||||
;;;
|
||||
;;; This program is distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;;; GNU General Public License for more details.
|
||||
;;;
|
||||
;;; You should have received a copy of the GNU General Public License
|
||||
;;; along with this program; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
;; Changes
|
||||
;;
|
||||
;; When Who What
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; 1999-08-15 GB - ROD=, ROD-EQUAL
|
||||
;; RUNE<=, RUNE>=
|
||||
;; MAKE-ROD, ROD-SUBSEQ
|
||||
;; CHAR-RUNE, RUNE-CHAR, ROD-STRING, STRING-ROD
|
||||
;; new functions
|
||||
;; - Added rune reader
|
||||
;;
|
||||
|
||||
(in-package :glisp)
|
||||
|
||||
;;;;
|
||||
;;;; RUNE Reader
|
||||
;;;;
|
||||
|
||||
;; Portable implementation of WHITE-SPACE-P with regard to the current
|
||||
;; read table -- this is bit tricky.
|
||||
|
||||
(defun rt-white-space-p (char)
|
||||
(let ((stream (make-string-input-stream (string char))))
|
||||
(eq :eof (peek-char t stream nil :eof))))
|
||||
|
||||
(defun read-rune-name (input)
|
||||
;; the first char is unconditionally read
|
||||
(let ((char0 (read-char input t nil t)))
|
||||
(when (char= char0 #\\)
|
||||
(setf char0 (read-char input t nil t)))
|
||||
(with-output-to-string (res)
|
||||
(write-char char0 res)
|
||||
(do ((ch (peek-char nil input nil :eof t) (peek-char nil input nil :eof t)))
|
||||
((or (eq ch :eof)
|
||||
(rt-white-space-p ch)
|
||||
(multiple-value-bind (function non-terminating-p) (get-macro-character ch)
|
||||
(and function (not non-terminating-p)))))
|
||||
(write-char ch res)
|
||||
(read-char input))))) ;consume this character
|
||||
|
||||
(defun iso-10646-char-code (char)
|
||||
(char-code char))
|
||||
|
||||
(defvar *rune-names* (make-hash-table :test #'equal)
|
||||
"Hashtable, which maps all known rune names to rune codes;
|
||||
Names are stored in uppercase.")
|
||||
|
||||
(defun define-rune-name (name code)
|
||||
(setf (gethash (string-upcase name) *rune-names*) code)
|
||||
name)
|
||||
|
||||
(defun lookup-rune-name (name)
|
||||
(gethash (string-upcase name) *rune-names*))
|
||||
|
||||
(define-rune-name "null" #x0000)
|
||||
(define-rune-name "space" #x0020)
|
||||
(define-rune-name "newline" #x000A)
|
||||
(define-rune-name "return" #x000D)
|
||||
(define-rune-name "tab" #x0009)
|
||||
(define-rune-name "page" #x000C)
|
||||
|
||||
;; and just for fun:
|
||||
(define-rune-name "euro" #x20AC)
|
||||
|
||||
;; ASCII control characters
|
||||
(define-rune-name "nul" #x0000) ;null
|
||||
(define-rune-name "soh" #x0001) ;start of header
|
||||
(define-rune-name "stx" #x0002) ;start of text
|
||||
(define-rune-name "etx" #x0003) ;end of text
|
||||
(define-rune-name "eot" #x0004) ;end of transmission
|
||||
(define-rune-name "enq" #x0005) ;
|
||||
(define-rune-name "ack" #x0006) ;acknowledge
|
||||
(define-rune-name "bel" #x0007) ;bell
|
||||
(define-rune-name "bs" #x0008) ;backspace
|
||||
(define-rune-name "ht" #x0009) ;horizontal tab
|
||||
(define-rune-name "lf" #X000A) ;line feed, new line
|
||||
(define-rune-name "vt" #X000B) ;vertical tab
|
||||
(define-rune-name "ff" #x000C) ;form feed
|
||||
(define-rune-name "cr" #x000D) ;carriage return
|
||||
(define-rune-name "so" #x000E) ;shift out
|
||||
(define-rune-name "si" #x000F) ;shift in
|
||||
(define-rune-name "dle" #x0010) ;device latch enable ?
|
||||
(define-rune-name "dc1" #x0011) ;device control 1
|
||||
(define-rune-name "dc2" #x0012) ;device control 2
|
||||
(define-rune-name "dc3" #x0013) ;device control 3
|
||||
(define-rune-name "dc4" #x0014) ;device control 4
|
||||
(define-rune-name "nak" #x0015) ;negative acknowledge
|
||||
(define-rune-name "syn" #x0016) ;
|
||||
(define-rune-name "etb" #x0017) ;
|
||||
(define-rune-name "can" #x0018) ;
|
||||
(define-rune-name "em" #x0019) ;end of message
|
||||
(define-rune-name "sub" #x001A) ;
|
||||
(define-rune-name "esc" #x001B) ;escape
|
||||
(define-rune-name "fs" #x001C) ;field separator ?
|
||||
(define-rune-name "gs" #x001D) ;group separator
|
||||
(define-rune-name "rs" #x001E) ;
|
||||
(define-rune-name "us" #x001F) ;
|
||||
|
||||
(define-rune-name "del" #x007F) ;delete
|
||||
|
||||
;; iso-latin
|
||||
(define-rune-name "nbsp" #x00A0) ;non breakable space
|
||||
(define-rune-name "shy" #x00AD) ;soft hyphen
|
||||
|
||||
(defun rune-from-read-name (name)
|
||||
(cond ((= (length name) 1)
|
||||
(iso-10646-char-code (char name 0)))
|
||||
((and (= (length name) 2)
|
||||
(char= (char name 0) #\\))
|
||||
(iso-10646-char-code (char name 1)))
|
||||
((and (>= (length name) 3)
|
||||
(char-equal (char name 0) #\u)
|
||||
(char-equal (char name 1) #\+)
|
||||
(every (lambda (x) (digit-char-p x 16)) (subseq name 2)))
|
||||
(parse-integer name :start 2 :radix 16))
|
||||
((lookup-rune-name name))
|
||||
(t
|
||||
(error "Meaningless rune name ~S." name))))
|
||||
|
||||
(defun rune-reader (stream subchar arg)
|
||||
subchar arg
|
||||
(values (rune-from-read-name (read-rune-name stream))))
|
||||
|
||||
(set-dispatch-macro-character #\# #\/ 'rune-reader)
|
||||
|
||||
;;; ROD ext syntax
|
||||
|
||||
(defun rod-reader (stream subchar arg)
|
||||
(declare (ignore arg))
|
||||
(rod
|
||||
(with-output-to-string (bag)
|
||||
(do ((c (read-char stream t nil t)
|
||||
(read-char stream t nil t)))
|
||||
((char= c subchar))
|
||||
(cond ((char= c #\\)
|
||||
(setf c (read-char stream t nil t))))
|
||||
(princ c bag)))))
|
||||
|
||||
(defun rod-printer (stream rod)
|
||||
(princ #\# stream)
|
||||
(princ #\" stream)
|
||||
(loop for x across rod do
|
||||
(cond ((or (rune= x #.(char-code #\\))
|
||||
(rune= x #.(char-code #\")))
|
||||
(princ #\\ stream)
|
||||
(princ (code-char x) stream))
|
||||
((< x char-code-limit)
|
||||
(princ (code-char x) stream))
|
||||
(t
|
||||
(format stream "\\u~4,'0X" x))))
|
||||
(princ #\" stream))
|
||||
|
||||
(set-pprint-dispatch '(satisfies really-rod-p) #'rod-printer)
|
||||
|
||||
(set-dispatch-macro-character #\# #\" 'rod-reader)
|
||||
|
||||
#||
|
||||
(defun longish-array-p (arr)
|
||||
(and (arrayp arr)
|
||||
(> (array-total-size arr) 10)))
|
||||
|
||||
(set-pprint-dispatch '(satisfies longish-array-p)
|
||||
#'(lambda (stream object)
|
||||
(let ((*print-array* nil)
|
||||
(*print-pretty* nil))
|
||||
(prin1 object stream))))
|
||||
||#
|
||||
1113
glisp/util.lisp
Normal file
1113
glisp/util.lisp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user