diff options
| author | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 | 
|---|---|---|
| committer | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 | 
| commit | a15cf65c44d5c224169c32ef5495b68c758134b7 (patch) | |
| tree | 3419f58fc8e1b315ba8171910ee044c5d467c162 /libfrontend-elements | |
Imported Upstream version 3.3.0.2upstream/3.3.0.2
Diffstat (limited to 'libfrontend-elements')
42 files changed, 2644 insertions, 0 deletions
| diff --git a/libfrontend-elements/GPLv2 b/libfrontend-elements/GPLv2 new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/libfrontend-elements/GPLv2 @@ -0,0 +1,340 @@ +		    GNU GENERAL PUBLIC LICENSE +		       Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. +                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +			    Preamble + +  The licenses for most software are designed to take away your +freedom to share and change it.  By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users.  This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it.  (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.)  You can apply it to +your programs, too. + +  When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + +  To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + +  For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have.  You must make sure that they, too, receive or can get the +source code.  And you must show them these terms so they know their +rights. + +  We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +  Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software.  If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +  Finally, any free program is threatened constantly by software +patents.  We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary.  To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + +  The precise terms and conditions for copying, distribution and +modification follow. + +		    GNU GENERAL PUBLIC LICENSE +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +  0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License.  The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language.  (Hereinafter, translation is included without limitation in +the term "modification".)  Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope.  The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +  1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices +    stating that you changed the files and the date of any change. + +    b) You must cause any work that you distribute or publish, that in +    whole or in part contains or is derived from the Program or any +    part thereof, to be licensed as a whole at no charge to all third +    parties under the terms of this License. + +    c) If the modified program normally reads commands interactively +    when run, you must cause it, when started running for such +    interactive use in the most ordinary way, to print or display an +    announcement including an appropriate copyright notice and a +    notice that there is no warranty (or else, saying that you provide +    a warranty) and that users may redistribute the program under +    these conditions, and telling the user how to view a copy of this +    License.  (Exception: if the Program itself is interactive but +    does not normally print such an announcement, your work based on +    the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole.  If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +  3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + +    a) 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; or, + +    b) Accompany it with a written offer, valid for at least three +    years, to give any third party, for a charge no more than your +    cost of physically performing source distribution, a complete +    machine-readable copy of the corresponding source code, to be +    distributed under the terms of Sections 1 and 2 above on a medium +    customarily used for software interchange; or, + +    c) Accompany it with the information you received as to the offer +    to distribute corresponding source code.  (This alternative is +    allowed only for noncommercial distribution and only if you +    received the program in object code or executable form with such +    an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it.  For an executable work, 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 executable.  However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +  4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License.  Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + +  5. 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 Program or its derivative works.  These actions are +prohibited by law if you do not accept this License.  Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +  6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + +  7. 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 Program at all.  For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + +  8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + +  9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +  10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + +  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU.  SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +  12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +		     END OF TERMS AND CONDITIONS + +	    How to Apply These Terms to Your New Programs + +  If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +  To do so, attach the following notices to the program.  It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + +    <one line to give the program's name and a brief idea of what it does.> +    Copyright (C) <year>  <name of author> + +    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +    Gnomovision version 69, Copyright (C) year name of author +    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. +    This is free software, and you are welcome to redistribute it +    under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License.  Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary.  Here is a sample; alter the names: + +  Yoyodyne, Inc., hereby disclaims all copyright interest in the program +  `Gnomovision' (which makes passes at compilers) written by James Hacker. + +  <signature of Ty Coon>, 1 April 1989 +  Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs.  If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library.  If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libfrontend-elements/INSTALL b/libfrontend-elements/INSTALL new file mode 100644 index 0000000..0f8459c --- /dev/null +++ b/libfrontend-elements/INSTALL @@ -0,0 +1,25 @@ +Prerequisites + +  build-time: + +    - build >= 0.3.2      http://www.codesynthesis.com/projects/build/ +    - g++ >= 3.4.3        http://gcc.gnu.org + +  run-time: + +    - libcult >= 1.4.1    http://kolpackov.net/projects/libcult/ + + +Building libfrontend-elements + +  To build in the source directory simply say `make'. You can also +  build in a separate directory, e.g., + +  $ mkdir libfrontend-elements-i686-pc-linux-gnu +  $ cd libfrontend-elements-i686-pc-linux-gnu +  $ make -f ../libfrontend-elements-x.y.z/makefile + + +Installing libfrontend-elements + +  Not supported in this version. diff --git a/libfrontend-elements/LICENSE b/libfrontend-elements/LICENSE new file mode 100644 index 0000000..3204be4 --- /dev/null +++ b/libfrontend-elements/LICENSE @@ -0,0 +1,25 @@ +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +In addition, as a special exception, Boris Kolpackov gives permission +to combine this library with other incompatibly-licensed modules in a +single program and to distribute such a combination provided that there +is no use of the functionality implemented by this library, directly +or indirectly, by such modules. You must obey the GNU General Public +License version 2 in all respects for all of the code used other than +such modules. In particular, the resulting program must be licensed +under a license compatible with the GNU General Public License version +2. If you modify this copy of the library, you may extend this exception +to your version of the library, but you are not obligated to do so. If +you do not wish to do so, delete this exception statement from your +version. diff --git a/libfrontend-elements/NEWS b/libfrontend-elements/NEWS new file mode 100644 index 0000000..68e3e22 --- /dev/null +++ b/libfrontend-elements/NEWS @@ -0,0 +1,40 @@ +Version 1.1.4 + +  * Add swap() to the context class. + +Version 1.1.3 + +  * Add support for libfrontend-elements bundling. + +Version 1.1.2 + +  * Add an exception to the licensing terms to allow combining with +    incompatibly-licensed modules in a single program. See the LICENSE +    file for details. + +Version 1.1.1 + +  * Fixed a bug in import stubs. +   +  * Got rid of warnings. + +Version 1.1.0 + +  * Upgraded to build-0.3.0. +   +Version 1.0.3 + +  * Added non-const get function to context which returns non-const +    reference. + +Version 1.0.2 + +  * Upgraded to build-0.2.0. + +Version 1.0.1 + +  * Build system improvements. + +Version 1.0.0 + +  * First public release. diff --git a/libfrontend-elements/README b/libfrontend-elements/README new file mode 100644 index 0000000..7db441e --- /dev/null +++ b/libfrontend-elements/README @@ -0,0 +1,14 @@ +libfrontend-elements is a collection of elementary building blocks +for implementing compiler frontends in c++. + +See the NEWS file for the user-visible changes from the previous release. + +See the LICENSE file for distribution conditions. + +See the INSTALL file for prerequisites and installation instructions. + +See the documentation/index.xhtml file for documentation. + +The project page is at http://kolpackov.net/projects/libfrontend-elements/. + +Send bug reports or any other feedback to boris@kolpackov.net . diff --git a/libfrontend-elements/build/bootstrap.make b/libfrontend-elements/build/bootstrap.make new file mode 100644 index 0000000..cafe739 --- /dev/null +++ b/libfrontend-elements/build/bootstrap.make @@ -0,0 +1,46 @@ +# file      : build/bootstrap.make +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +project_name := libfrontend-elements + +# First try to include the bundled bootstrap.make if it exist. If that +# fails, let make search for the external bootstrap.make. +# +build := build-0.3 + +-include $(dir $(lastword $(MAKEFILE_LIST)))../../$(build)/bootstrap.make + +ifeq ($(patsubst %build/bootstrap.make,,$(lastword $(MAKEFILE_LIST))),) +include $(build)/bootstrap.make +endif + +# Aliases +# +.PHONY: $(out_base)/       \ +        $(out_base)/.test  \ +        $(out_base)/.clean + +ifdef %interactive% + +.PHONY: test clean + +test: $(out_base)/.test +clean: $(out_base)/.clean + +ifneq ($(filter $(.DEFAULT_GOAL),test clean),) +.DEFAULT_GOAL := +endif + +endif + +# Don't include dependency info for certain targets. +# +define include-dep +$(call -include,$1) +endef + +ifneq ($(filter $(MAKECMDGOALS),clean cleandoc disfigure),) +include-dep = +endif diff --git a/libfrontend-elements/build/cxx/configuration-dynamic.make b/libfrontend-elements/build/cxx/configuration-dynamic.make new file mode 100644 index 0000000..568ab40 --- /dev/null +++ b/libfrontend-elements/build/cxx/configuration-dynamic.make @@ -0,0 +1,14 @@ +cxx_id       := gnu +cxx_optimize := n +cxx_debug    := n +cxx_rpath    := n +cxx_pp_extra_options := $(CPPFLAGS) +cxx_extra_options    := $(CXXFLAGS) +cxx_ld_extra_options := $(LDFLAGS) +cxx_extra_libs       := $(LIBS) + +r := $(shell echo $(LDFLAGS) | sed -e 's/-L *\([^ ]*\)/-L\1/g') +r := $(patsubst -L%,%,$(filter -L%,$(r))) +r := $(shell echo $(r) | sed -e 's/ /:/g') + +cxx_extra_lib_paths  := $(r) diff --git a/libfrontend-elements/build/cxx/gnu/configuration-dynamic.make b/libfrontend-elements/build/cxx/gnu/configuration-dynamic.make new file mode 100644 index 0000000..f3fe64d --- /dev/null +++ b/libfrontend-elements/build/cxx/gnu/configuration-dynamic.make @@ -0,0 +1,8 @@ +ifneq ($(CXX),) +cxx_gnu := $(CXX) +else +cxx_gnu := g++ +endif + +cxx_gnu_libraries :=  +cxx_gnu_optimization_options := diff --git a/libfrontend-elements/build/export/libfrontend-elements/stub.make b/libfrontend-elements/build/export/libfrontend-elements/stub.make new file mode 100644 index 0000000..27c0940 --- /dev/null +++ b/libfrontend-elements/build/export/libfrontend-elements/stub.make @@ -0,0 +1,10 @@ +# file      : build/import/libfrontend-elements/stub.make +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(src_root)/frontend-elements/makefile,$(out_root)) + +$(call export,\ +  l: $(out_root)/frontend-elements/frontend-elements.l,\ +  cpp-options: $(out_root)/frontend-elements/frontend-elements.l.cpp-options) diff --git a/libfrontend-elements/build/import/libcult/LICENSE b/libfrontend-elements/build/import/libcult/LICENSE new file mode 100644 index 0000000..3912109 --- /dev/null +++ b/libfrontend-elements/build/import/libcult/LICENSE @@ -0,0 +1,340 @@ +		    GNU GENERAL PUBLIC LICENSE +		       Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. +                       51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +			    Preamble + +  The licenses for most software are designed to take away your +freedom to share and change it.  By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users.  This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it.  (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.)  You can apply it to +your programs, too. + +  When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + +  To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + +  For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have.  You must make sure that they, too, receive or can get the +source code.  And you must show them these terms so they know their +rights. + +  We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +  Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software.  If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +  Finally, any free program is threatened constantly by software +patents.  We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary.  To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + +  The precise terms and conditions for copying, distribution and +modification follow. + +		    GNU GENERAL PUBLIC LICENSE +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +  0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License.  The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language.  (Hereinafter, translation is included without limitation in +the term "modification".)  Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope.  The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + +  1. You may copy and distribute verbatim copies of the Program's +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 give any other recipients of the Program a copy of this License +along with the Program. + +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 Program or any portion +of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices +    stating that you changed the files and the date of any change. + +    b) You must cause any work that you distribute or publish, that in +    whole or in part contains or is derived from the Program or any +    part thereof, to be licensed as a whole at no charge to all third +    parties under the terms of this License. + +    c) If the modified program normally reads commands interactively +    when run, you must cause it, when started running for such +    interactive use in the most ordinary way, to print or display an +    announcement including an appropriate copyright notice and a +    notice that there is no warranty (or else, saying that you provide +    a warranty) and that users may redistribute the program under +    these conditions, and telling the user how to view a copy of this +    License.  (Exception: if the Program itself is interactive but +    does not normally print such an announcement, your work based on +    the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole.  If +identifiable sections of that work are not derived from the Program, +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 Program, 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 Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + +  3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + +    a) 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; or, + +    b) Accompany it with a written offer, valid for at least three +    years, to give any third party, for a charge no more than your +    cost of physically performing source distribution, a complete +    machine-readable copy of the corresponding source code, to be +    distributed under the terms of Sections 1 and 2 above on a medium +    customarily used for software interchange; or, + +    c) Accompany it with the information you received as to the offer +    to distribute corresponding source code.  (This alternative is +    allowed only for noncommercial distribution and only if you +    received the program in object code or executable form with such +    an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it.  For an executable work, 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 executable.  However, as a +special exception, the source code 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. + +If distribution of executable or 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 counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + +  4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License.  Any attempt +otherwise to copy, modify, sublicense or distribute the Program 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. + +  5. 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 Program or its derivative works.  These actions are +prohibited by law if you do not accept this License.  Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + +  6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program 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 to +this License. + +  7. 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 Program at all.  For example, if a patent +license would not permit royalty-free redistribution of the Program 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 Program. + +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. + +  8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program 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. + +  9. The Free Software Foundation may publish revised and/or new versions +of the 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 Program +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 Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + +  10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, 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 + +  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU.  SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + +  12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +		     END OF TERMS AND CONDITIONS + +	    How to Apply These Terms to Your New Programs + +  If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + +  To do so, attach the following notices to the program.  It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + +    <one line to give the program's name and a brief idea of what it does.> +    Copyright (C) <year>  <name of author> + +    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + +    Gnomovision version 69, Copyright (C) year name of author +    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. +    This is free software, and you are welcome to redistribute it +    under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License.  Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary.  Here is a sample; alter the names: + +  Yoyodyne, Inc., hereby disclaims all copyright interest in the program +  `Gnomovision' (which makes passes at compilers) written by James Hacker. + +  <signature of Ty Coon>, 1 April 1989 +  Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs.  If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library.  If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/libfrontend-elements/build/import/libcult/configuration-dynamic.make b/libfrontend-elements/build/import/libcult/configuration-dynamic.make new file mode 100644 index 0000000..73c92bb --- /dev/null +++ b/libfrontend-elements/build/import/libcult/configuration-dynamic.make @@ -0,0 +1,4 @@ +libcult_installed := n +src_root := $(abspath $(src_root)/../libcult) +scf_root := $(src_root)/build +out_root := $(src_root) diff --git a/libfrontend-elements/build/import/libcult/configuration-rules.make b/libfrontend-elements/build/import/libcult/configuration-rules.make new file mode 100644 index 0000000..dc19df4 --- /dev/null +++ b/libfrontend-elements/build/import/libcult/configuration-rules.make @@ -0,0 +1,15 @@ +# file      : build/import/libcult/configuration-rules.make +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2009 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libcult/configuration-dynamic.make: | $(dcf_root)/import/libcult/. +	$(call message,,$(scf_root)/import/libcult/configure $@) + +ifndef %foreign% + +disfigure:: +	$(call message,rm $(dcf_root)/import/libcult/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/libcult/configuration-dynamic.make) + +endif diff --git a/libfrontend-elements/build/import/libcult/configure b/libfrontend-elements/build/import/libcult/configure new file mode 100755 index 0000000..afa4c9c --- /dev/null +++ b/libfrontend-elements/build/import/libcult/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file      : build/import/libcult/configure +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2009 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + + +# $1           - out file +# +# bld_root     - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo "Configuring external dependency on 'libcult' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed " +$echo "version of 'libcult' as opposed to the development build?" +$echo + +installed=`read_y_n y` + +path= + +if [ "$installed" = "n" ]; then + +$echo +$echo "Please enter the src_root for 'libcult'." +$echo + +src_root=`read_path --directory --exist` + +$echo +$echo "Please enter the out_root for 'libcult'." +$echo + +out_root=`read_path --directory $src_root` + +fi + +echo libcult_installed := $installed   >$1 + +if [ "$installed" = "n" ]; then + +echo src_root := $src_root            >>$1 +echo scf_root := \$\(src_root\)/build >>$1 +echo out_root := $out_root            >>$1 + +fi diff --git a/libfrontend-elements/build/import/libcult/stub.make b/libfrontend-elements/build/import/libcult/stub.make new file mode 100644 index 0000000..f5f7691 --- /dev/null +++ b/libfrontend-elements/build/import/libcult/stub.make @@ -0,0 +1,30 @@ +# file      : build/import/libcult/stub.make +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2009 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/libcult/configuration-rules.make,$(dcf_root)) + +libcult_installed := + +$(call -include,$(dcf_root)/import/libcult/configuration-dynamic.make) + +ifdef libcult_installed + +ifeq ($(libcult_installed),y) + +$(call export,l: -lcult,cpp-options: ) + +else + +# Include export stub. +# +$(call include,$(scf_root)/export/libcult/stub.make) + +endif + +else + +.NOTPARALLEL: + +endif diff --git a/libfrontend-elements/build/import/libfrontend-elements/LICENSE b/libfrontend-elements/build/import/libfrontend-elements/LICENSE new file mode 120000 index 0000000..5853aae --- /dev/null +++ b/libfrontend-elements/build/import/libfrontend-elements/LICENSE @@ -0,0 +1 @@ +../../../LICENSE
\ No newline at end of file diff --git a/libfrontend-elements/build/import/libfrontend-elements/configuration-rules.make b/libfrontend-elements/build/import/libfrontend-elements/configuration-rules.make new file mode 100644 index 0000000..ab45f1c --- /dev/null +++ b/libfrontend-elements/build/import/libfrontend-elements/configuration-rules.make @@ -0,0 +1,15 @@ +# file      : build/import/libfrontend-elements/configuration-rules.make +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +$(dcf_root)/import/libfrontend-elements/configuration-dynamic.make: | $(dcf_root)/import/libfrontend-elements/. +	$(call message,,$(scf_root)/import/libfrontend-elements/configure $@) + +ifndef %foreign% + +disfigure:: +	$(call message,rm $(dcf_root)/import/libfrontend-elements/configuration-dynamic.make,\ +rm -f $(dcf_root)/import/libfrontend-elements/configuration-dynamic.make) + +endif diff --git a/libfrontend-elements/build/import/libfrontend-elements/configure b/libfrontend-elements/build/import/libfrontend-elements/configure new file mode 100755 index 0000000..c0b60f4 --- /dev/null +++ b/libfrontend-elements/build/import/libfrontend-elements/configure @@ -0,0 +1,55 @@ +#! /usr/bin/env bash + +# file      : build/import/libfrontend-elements/configure +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + + +# $1           - out file +# +# bld_root     - build root +# project_name - project name +# + +source $bld_root/dialog.bash + + +$echo +$echo "Configuring external dependency on 'libfrontend-elements' for '$project_name'." +$echo + +$echo +$echo "Would you like to configure dependency on the installed version" +$echo "of 'libfrontend-elements' as opposed to the development build?" +$echo + +installed=`read_y_n y` + +path= + +if [ "$installed" = "n" ]; then + +$echo +$echo "Please enter the src_root for 'libfrontend-elements'." +$echo + +src_root=`read_path --directory --exist` + +$echo +$echo "Please enter the out_root for 'libfrontend-elements'." +$echo + +out_root=`read_path --directory $src_root` + +fi + +echo libfrontend_elements_installed := $installed   >$1 + +if [ "$installed" = "n" ]; then + +echo src_root := $src_root            >>$1 +echo scf_root := \$\(src_root\)/build >>$1 +echo out_root := $out_root            >>$1 + +fi diff --git a/libfrontend-elements/build/import/libfrontend-elements/stub.make b/libfrontend-elements/build/import/libfrontend-elements/stub.make new file mode 100644 index 0000000..7eb1153 --- /dev/null +++ b/libfrontend-elements/build/import/libfrontend-elements/stub.make @@ -0,0 +1,30 @@ +# file      : build/import/libfrontend-elements/stub.make +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +$(call include-once,$(scf_root)/import/libfrontend-elements/configuration-rules.make,$(dcf_root)) + +libfrontend_elements_installed := + +$(call -include,$(dcf_root)/import/libfrontend-elements/configuration-dynamic.make) + +ifdef libfrontend_elements_installed + +ifeq ($(libfrontend_elements_installed),y) + +$(call export,l: -lfrontend-elements -lcult,cpp_options: ) + +else + +# Include export stub. +# +$(call include,$(scf_root)/export/libfrontend-elements/stub.make) + +endif + +else + +.NOTPARALLEL: + +endif diff --git a/libfrontend-elements/build/ld/configuration-lib-dynamic.make b/libfrontend-elements/build/ld/configuration-lib-dynamic.make new file mode 100644 index 0000000..74c8885 --- /dev/null +++ b/libfrontend-elements/build/ld/configuration-lib-dynamic.make @@ -0,0 +1,13 @@ +ld_lib_type   := archive + +ifneq ($(AR),) +ld_lib_ar     := $(AR) +else +ld_lib_ar     := ar +endif + +ifneq ($(RANLIB),) +ld_lib_ranlib := $(RANLIB) +else +ld_lib_ranlib := ranlib +endif diff --git a/libfrontend-elements/documentation/DIAGNOSTIC b/libfrontend-elements/documentation/DIAGNOSTIC new file mode 100644 index 0000000..b9b6004 --- /dev/null +++ b/libfrontend-elements/documentation/DIAGNOSTIC @@ -0,0 +1,4 @@ +@@ How am I going to address the problem of translation? + +@@ Check Cult::Trace for any new ideas. + diff --git a/libfrontend-elements/documentation/TODO b/libfrontend-elements/documentation/TODO new file mode 100644 index 0000000..27d4041 --- /dev/null +++ b/libfrontend-elements/documentation/TODO @@ -0,0 +1 @@ +@@ Add example for traversal. diff --git a/libfrontend-elements/documentation/default.css b/libfrontend-elements/documentation/default.css new file mode 100644 index 0000000..7242a94 --- /dev/null +++ b/libfrontend-elements/documentation/default.css @@ -0,0 +1,160 @@ +body { +  font-family      : sans-serif; +  font-weight      : normal; + +  color            : black; +  background       : white; + +  max-width        : 42em; +  padding          : 2em 2em 2em 3em; +  margin           : 0 auto; +} + +h1, h2, h3, h4, h5, h6 { +  font-family      : sans-serif; +  font-weight      : 500; +} + +h1 { font-size     : 170%; } +h2 { font-size     : 145%; } +h3 { font-size     : 125%; } +h4 { font-size     : 110%; } +h5 { font-size     : 106%; } +h6 { font-size     : 100%; } + + +p.indent { +  margin-left      : 1.5em; +} + + +/* table of content */ +ul.toc li { +    padding        : .4em 0em 0em 0em; +} + + + +/* list of links */ +ul.menu { +  list-style-type  : none; +} + +ul.menu li { +  padding-top      : 0.3em; +  padding-bottom   : 0.3em; +} + + + +/* @@ I should probably use child selector here */ +/* list with multiline list-elements */ +ul.multiline li { +  padding-top      : 0.4em; +  padding-bottom   : 0.4em; +} + +ol.multiline li { +  padding-top      : 0.4em; +  padding-bottom   : 0.4em; +} + +dl.multiline dd { +  padding-top      : 0.4em; +  padding-bottom   : 0.4em; +} + +/* code */ + +code { +  font-size     : 114%; +  font-family   : monospace; +} + + +/* C++ code snippet */ +pre.cxx { + +  margin-top       : 0em; +  margin-bottom    : 2em; + +  margin-left      : 1em; +} + + + +/* make code snippet */ +pre.make { + +  margin-top       : 0em; +  margin-bottom    : 2em; + +  margin-left      : 1em; +} + + + +/* terminal output */ +pre.term { + +  margin-top       : 0em; +  margin-bottom    : 2em; + +  margin-left      : 1em; +} + + +/* Images */ +div.center { +  text-align: center; +} + +/* Navigation. */ +#navigation { +  margin-top: 1em; +  border-bottom: 1px dashed #000000; +} + +#content { +  margin-top: 2.5em; +} + + +/* Document info. */ +#docinfo { +  margin-top: 4em; +  border-top: 1px dashed #000000; +  font-size: 70%; +} + +/* distribution terms */ +div.terms { +  font-size     : 114%; +  font-family      : monospace; +} + + + +/* Footnote */ + +#footnote { +  margin-top: 2em; +} + +#footnote hr { +  margin-left: 0; +  margin-bottom: 1.5em; +  width: 8em; +  border-top: 1px solid #000000; +  border-right: none; +  border-bottom: none; +  border-left: none; + +} + +#footnote p { +  font-size: .91em; +  text-indent: -0.8em; +  padding-left: 0.8em; +} + diff --git a/libfrontend-elements/documentation/index.xhtml b/libfrontend-elements/documentation/index.xhtml new file mode 100644 index 0000000..ad12e50 --- /dev/null +++ b/libfrontend-elements/documentation/index.xhtml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> + +<!-- + +file      : documentation/index.xhtml +author    : Boris Kolpackov <boris@kolpackov.net> +copyright : Copyright (c) 2005-2010 Boris Kolpackov +license   : GNU FDL v1.2; http://kolpackov.net/licenses/fdl-1.2.txt + +--> + +<head> + +  <title>libfrontend-elements/documentation</title> + +  <meta name="author" content="Boris Kolpackov"/> +  <meta name="copyright" content="© 2005-2010 Boris Kolpackov"/> +  <meta name="keywords" content="c++,library,compiler,frontend"/> +  <meta name="description" content="libfrontend-elements/documentation"/> + +  <link rel="stylesheet" type="text/css" href="default.css"/> + +</head> + +<body> + +<div id="navigation"> +<p> +<a href=".."><code>libfrontend-elements</code></a> <code>/</code> +<code>documentation</code> +</p> +</div> + +<div id="content"> +<p><i>libfrontend-elements</i> consists of the following +elements:</p> + +<ul class="menu"> +  <li><code>context</code></li> +  <li><code>diagnostic</code></li> +  <li><code>token-stream</code></li> +  <li><code>traversal</code></li> +</ul> + + +<p>Context is essentially a heterogeneous map of names to instances of +arbitrary types. It is primarily used to allow arbitrary annotations of +<em>semantic graph</em> nodes and edges, which are often useful +during code generation.</p> + +<p>Diagnostic framework allows to implement consistent and extensible +compiler diagnostic without incurring significant notational burden.</p> + +<p><code>TokenStream</code> is a generic interface which is usually +implemented by a <em>lexical analyzer</em>.</p> + +<p>Traversal is a significant enhancement of a well-known <em>visitor</em> +idiom which is often used to traverse <em>semantic graphs</em>.</p> + +</div> + +<div id="docinfo"> +<p>Copyright © 2005-2010 <a title="Boris Kolpackov" +href="http://kolpackov.net">Boris Kolpackov</a>.</p> + +<div class="terms"> +Permission is granted to copy, distribute and/or modify this document under +the terms of the <a href="http://kolpackov.net/licenses/fdl-1.2.txt">GNU Free +Documentation License, version 1.2</a>; with no Invariant Sections, no +Front-Cover Texts and no Back-Cover Texts. +</div> +</div> + +</body> +</html> diff --git a/libfrontend-elements/examples/diagnostic/driver.cxx b/libfrontend-elements/examples/diagnostic/driver.cxx new file mode 100644 index 0000000..edb8a18 --- /dev/null +++ b/libfrontend-elements/examples/diagnostic/driver.cxx @@ -0,0 +1,29 @@ +// file      : examples/diagnostic/driver.cxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <cult/types.hxx> + +#include <frontend-elements/diagnostic.hxx> + +using namespace Cult::Types; +using namespace FrontendElements::Diagnostic; + +// Some ideas: The first letter (`e') in `epsyntx' is for error. +// The second letter identifies part of the system (p - parser). +// +// +Error epsyntx ("EPSYNTX"); + +Warning wscoer ("WS001"); + +Stream dout; + +Int +main () +{ +  dout << epsyntx << "foo.cxx" << 1UL << 12UL << "syntax error"; + +  dout << wscoer << "foo.cxx" << 2UL << "type coercion"; +} diff --git a/libfrontend-elements/examples/diagnostic/makefile b/libfrontend-elements/examples/diagnostic/makefile new file mode 100644 index 0000000..0945a81 --- /dev/null +++ b/libfrontend-elements/examples/diagnostic/makefile @@ -0,0 +1,48 @@ +# file      : examples/diagnostic/makefile +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make + +cxx_tun   := driver.cxx +cxx_obj   := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od    := $(cxx_obj:.o=.o.d) + +frontend_elements.l             := $(out_root)/frontend-elements/frontend-elements.l +frontend_elements.l.cpp-options := $(out_root)/frontend-elements/frontend-elements.l.cpp-options + +diagnostic := $(out_base)/diagnostic +clean      := $(out_base)/.clean + + +# Build. +# +$(diagnostic): $(cxx_obj) $(frontend_elements.l) + +$(cxx_obj) $(cxx_od): $(frontend_elements.l.cpp-options) + +$(call include-dep,$(cxx_od)) + + +# Convenience alias for default target. +# +$(out_base)/: $(diagnostic) + + +# Clean. +# +$(clean): $(diagnostic).o.clean      \ +  $(addsuffix .cxx.clean,$(cxx_obj)) \ +  $(addsuffix .cxx.clean,$(cxx_od)) + + +# How to. +# +$(call include,$(bld_root)/cxx/o-e.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) + +# Dependencies. +# +$(call import,$(src_root)/frontend-elements/makefile) diff --git a/libfrontend-elements/examples/makefile b/libfrontend-elements/examples/makefile new file mode 100644 index 0000000..7d7abd3 --- /dev/null +++ b/libfrontend-elements/examples/makefile @@ -0,0 +1,16 @@ +# file      : examples/makefile +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +default   := $(out_base)/ +clean     := $(out_base)/.clean + +examples := $(out_base)/diagnostic + +$(default): $(addsuffix /,$(examples)) +$(clean): $(addsuffix /.clean,$(examples)) + +$(foreach e,$(subst $(out_base),$(src_base),$(examples)),$(call import,$e/makefile)) diff --git a/libfrontend-elements/frontend-elements/context.cxx b/libfrontend-elements/frontend-elements/context.cxx new file mode 100644 index 0000000..295ce74 --- /dev/null +++ b/libfrontend-elements/frontend-elements/context.cxx @@ -0,0 +1,11 @@ +// file      : frontend-elements/context.cxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <frontend-elements/context.hxx> + +namespace FrontendElements +{ +} + diff --git a/libfrontend-elements/frontend-elements/context.hxx b/libfrontend-elements/frontend-elements/context.hxx new file mode 100644 index 0000000..9a31da2 --- /dev/null +++ b/libfrontend-elements/frontend-elements/context.hxx @@ -0,0 +1,133 @@ +// file      : frontend-elements/context.hxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef FRONTEND_ELEMENTS_CONTEXT_HXX +#define FRONTEND_ELEMENTS_CONTEXT_HXX + +#include <frontend-elements/types.hxx> + +#include <cult/containers/any.hxx> +#include <cult/containers/map.hxx> + +namespace FrontendElements +{ +  class Context: public NonCopyable +  { +    typedef +    Cult::Containers::Map<String, Cult::Containers::Any> +    Map; + +  public: +    struct NoEntry {}; +    struct Typing {}; + +    Context () +    { +    } + +    Void +    swap (Context& c) +    { +      map_.swap (c.map_); +    } + +    Size +    count (Char const* key) const +    { +      return map_.count (key); +    } + +    template <typename X> +    X& +    get (Char const* key) +    { +      Map::Iterator i (map_.find (key)); + +      if (i == map_.end ()) +        throw NoEntry (); + +      try +      { +        return i->second. template value<X> (); +      } +      catch (Cult::Containers::Any::Typing const&) +      { +        throw Typing (); +      } +    } + +    template <typename X> +    X const& +    get (Char const* key) const +    { +      Map::ConstIterator i (map_.find (key)); + +      if (i == map_.end ()) +        throw NoEntry (); + +      try +      { +        return i->second. template value<X> (); +      } +      catch (Cult::Containers::Any::Typing const&) +      { +        throw Typing (); +      } +    } + +    template <typename X> +    X const& +    get (Char const* key, X const& default_value) const +    { +      Map::ConstIterator i (map_.find (key)); + +      if (i == map_.end ()) +        return default_value; + +      try +      { +        return i->second. template value<X> (); +      } +      catch (Cult::Containers::Any::Typing const&) +      { +        throw Typing (); +      } +    } + +    template <typename X> +    Void +    set (Char const* key, X const& value) +    { +      try +      { +        if (!map_.insert (Map::Pair (key, value)).second) +        { +          Map::Iterator i (map_.find (key)); +          i->second.template value <X> () = value; +        } +      } +      catch (Cult::Containers::Any::Typing const&) +      { +        throw Typing (); +      } +    } + +    Void +    remove (Char const* key) +    { +      Map::Iterator i (map_.find (key)); + +      if (i == map_.end ()) +        throw NoEntry (); + +      map_.erase (i); +    } + +  private: +    Map map_; +  }; +} + +#endif  // FRONTEND_ELEMENTS_CONTEXT_HXX diff --git a/libfrontend-elements/frontend-elements/diagnostic.cxx b/libfrontend-elements/frontend-elements/diagnostic.cxx new file mode 100644 index 0000000..c99061f --- /dev/null +++ b/libfrontend-elements/frontend-elements/diagnostic.cxx @@ -0,0 +1,41 @@ +// file      : frontend-elements/diagnostic.cxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <frontend-elements/diagnostic.hxx> + +#include <iostream> + +namespace FrontendElements +{ +  namespace Diagnostic +  { +    using std::cerr; +    using std::endl; + +    Log& Log:: +    operator<< (Record const& r) +    { +      cerr << r.file () << ":" << r.line (); + +      if (r.char_p ()) cerr << ":" << r.char_ (); + +      cerr << ": "; + +      r.kind ().print (cerr); + +      cerr << ": " << r.text () << endl; + +      return *this; +    } + +    Log& Log:: +    instance () +    { +      static Log l; +      return l; +    } +  } +} + diff --git a/libfrontend-elements/frontend-elements/diagnostic.hxx b/libfrontend-elements/frontend-elements/diagnostic.hxx new file mode 100644 index 0000000..6cc48da --- /dev/null +++ b/libfrontend-elements/frontend-elements/diagnostic.hxx @@ -0,0 +1,364 @@ +// file      : frontend-elements/diagnostic.hxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef FRONTEND_ELEMENTS_DIAGNOSTIC_HXX +#define FRONTEND_ELEMENTS_DIAGNOSTIC_HXX + +#include <frontend-elements/types.hxx> + +#include <ostream> +#include <sstream> + +namespace FrontendElements +{ +  namespace Diagnostic +  { +    struct Kind +    { +      virtual +      ~Kind () +      { +      } + +      Kind (String const& id) +          : id_ (id) +      { +      } + +      Char const* +      id () const +      { +        return id_.c_str (); +      } + +      virtual std::ostream& +      print (std::ostream& o) const = 0; + +    private: +      String id_; +    }; + +    struct Error: Kind +    { +      virtual +      ~Error () +      { +      } + +      Error (String const& id) +          : Kind (id) +      { +      } + +      virtual std::ostream& +      print (std::ostream& o) const +      { +        return o << "error " << id (); +      } +    }; + +    struct Warning: Kind +    { +      virtual +      ~Warning () +      { +      } + +      Warning (String const& id) +          : Kind (id) +      { +      } + +      virtual std::ostream& +      print (std::ostream& o) const +      { +        return o << "warning " << id (); +      } +    }; + +    struct Remark: Kind +    { +      virtual +      ~Remark () +      { +      } + +      Remark (String const& id) +          : Kind (id) +      { +      } + +      virtual std::ostream& +      print (std::ostream& o) const +      { +        return o << "remark " << id (); +      } +    }; + +    struct Info: Kind +    { +      virtual +      ~Info () +      { +      } + +      Info (String const& id) +          : Kind (id) +      { +      } + +      virtual std::ostream& +      print (std::ostream& o) const +      { +        return o << "info " << id (); +      } +    }; + +    // +    // +    // +    namespace Bits +    { +      class Mediator; +    } + +    class Record: public NonCopyable +    { +    public: +      Record (Kind const& kind, +              String const& file, +              UnsignedLong line, +              UnsignedLong char_) +          : kind_ (&kind), +            file_p_ (true), +            file_ (file), +            line_p_ (true), +            line_ (line), +            char_p_ (true), +            char__ (char_) +      { +      } + +      Record (Kind const& kind, +              String const& file, +              UnsignedLong line) +          : kind_ (&kind), +            file_p_ (true), +            file_ (file), +            line_p_ (true), +            line_ (line), +            char_p_ (false) +      { +      } + +    private: +      Record () +          : kind_ (0), +            file_p_ (false), +            line_p_ (false), +            char_p_ (false) +      { +      } + + +      Void +      kind (Kind const& kind) +      { +        kind_ = &kind; +      } + +      friend class Bits::Mediator; + +      friend Record& +      operator<< (Bits::Mediator const&, Kind const&); + +    public: +      class Undefined {}; + +      Kind const& +      kind () const +      { +        return *kind_; +      } + +      Char const* +      file () const +      { +        if (file_p_) return file_.c_str (); + +        throw Undefined (); +      } + +      UnsignedLong +      line () const +      { +        if (line_p_) return line_; + +        throw Undefined (); +      } + +      Boolean +      char_p () const +      { +        return char_p_; +      } + +      UnsignedLong +      char_ () const +      { +        if (char_p_) return char__; + +        throw Undefined (); +      } + +      String +      text () const +      { +        return o_.str (); +      } + +    public: +      Record& +      operator<< (Char const* s) +      { +        if (!char_p_ && !line_p_ && !file_p_) +        { +          file_ = s; +          file_p_ = true; +        } +        else +          o_ << s; + +        return *this; +      } + +      //@@ Make it Int. +      // +      Record& +      operator<< (UnsignedLong l) +      { +        if (file_p_ && !char_p_) +        { +          if (line_p_) +          { +            char__ = l; +            char_p_ = true; +          } +          else +          { +            line_ = l; +            line_p_ = true; +          } +        } +        else +          o_ << l; + +        return *this; +      } + +      template <typename X> +      Record& +      operator<< (X const& x) +      { +        o_ << x; +        return *this; +      } + +    private: +      Kind const* kind_; + +      Boolean file_p_; +      String file_; + +      Boolean line_p_; +      UnsignedLong line_; + +      Boolean char_p_; +      UnsignedLong char__; + +      std::ostringstream o_; +    }; + + +    // +    // +    // +    class Log: public NonCopyable +    { +    public: +      virtual +      ~Log () +      { +      } + +    public: +      virtual Log& +      operator<< (Record const& r); + +    public: +      static Log& +      instance (); +    }; + + +    // +    // +    // +    class Stream; + +    namespace Bits +    { +      class Mediator +      { +      public: +        Mediator (Stream& s) +            : s_ (s) +        { +        } + +        ~Mediator (); + +        Stream& s_; +        mutable Record r_; +      }; +    } + +    class Stream: public NonCopyable +    { +    public: +      Stream (Log& l = Log::instance ()) +          : log_ (l) +      { +      } + +    public: +      Stream& +      operator<< (Record const& r) +      { +        log_ << r; +        return *this; +      } + +      friend Record& +      operator<< (Bits::Mediator const& m, Kind const& k) +      { +        Record& r (m.r_); + +        r.kind (k); + +        return r; +      } + +    private: +      Log& log_; +    }; + +  } +} + +#include <frontend-elements/diagnostic.ixx> +#include <frontend-elements/diagnostic.txx> + +#endif  // FRONTEND_ELEMENTS_DIAGNOSTIC_HXX diff --git a/libfrontend-elements/frontend-elements/diagnostic.ixx b/libfrontend-elements/frontend-elements/diagnostic.ixx new file mode 100644 index 0000000..d32325d --- /dev/null +++ b/libfrontend-elements/frontend-elements/diagnostic.ixx @@ -0,0 +1,21 @@ +// file      : frontend-elements/diagnostic.ixx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace FrontendElements +{ +  namespace Diagnostic +  { +    namespace Bits +    { +      inline +      Mediator:: +      ~Mediator () +      { +        s_ << r_; +      } +    } +  } +} + diff --git a/libfrontend-elements/frontend-elements/diagnostic.txx b/libfrontend-elements/frontend-elements/diagnostic.txx new file mode 100644 index 0000000..b8391f4 --- /dev/null +++ b/libfrontend-elements/frontend-elements/diagnostic.txx @@ -0,0 +1,9 @@ +// file      : frontend-elements/diagnostic.txx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace FrontendElements +{ +} + diff --git a/libfrontend-elements/frontend-elements/makefile b/libfrontend-elements/frontend-elements/makefile new file mode 100644 index 0000000..8ca30b0 --- /dev/null +++ b/libfrontend-elements/frontend-elements/makefile @@ -0,0 +1,63 @@ +# file      : frontend-elements/makefile +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make + +cxx_tun   := context.cxx       \ +             diagnostic.cxx    \ +             token-stream.cxx  \ +             traversal.cxx + +cxx_obj   := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) +cxx_od    := $(cxx_obj:.o=.o.d) + +frontend_elements.l             := $(out_base)/frontend-elements.l +frontend_elements.l.cpp-options := $(out_base)/frontend-elements.l.cpp-options + +clean     := $(out_base)/.clean + + +# Secure default target. +# +$(frontend_elements.l): + + +# Import libcult. +# +$(call import,\ +  $(scf_root)/import/libcult/stub.make,\ +  l: cult.l,cpp-options: cult.l.cpp-options) + +# Build. +# +$(frontend_elements.l): $(cxx_obj) $(cult.l) + +$(cxx_obj) $(cxx_od): $(frontend_elements.l.cpp-options) + +$(frontend_elements.l.cpp-options): value := -I$(src_root) +$(frontend_elements.l.cpp-options): $(cult.l.cpp-options) + +$(call include-dep,$(cxx_od)) + + +# Convenience alias for default target. +# +$(out_base)/: $(frontend_elements.l) + + +# Clean. +# +$(clean): $(frontend_elements.l).o.clean     \ +  $(frontend_elements.l.cpp-options).clean \ +  $(addsuffix .cxx.clean,$(cxx_obj))           \ +  $(addsuffix .cxx.clean,$(cxx_od)) + + + +# How to. +# +$(call include,$(bld_root)/cxx/o-l.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/cxx-d.make) diff --git a/libfrontend-elements/frontend-elements/token-stream.cxx b/libfrontend-elements/frontend-elements/token-stream.cxx new file mode 100644 index 0000000..dab785a --- /dev/null +++ b/libfrontend-elements/frontend-elements/token-stream.cxx @@ -0,0 +1,10 @@ +// file      : frontend-elements/token-stream.cxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <frontend-elements/token-stream.hxx> + +namespace FrontendElements +{ +} diff --git a/libfrontend-elements/frontend-elements/token-stream.hxx b/libfrontend-elements/frontend-elements/token-stream.hxx new file mode 100644 index 0000000..023842f --- /dev/null +++ b/libfrontend-elements/frontend-elements/token-stream.hxx @@ -0,0 +1,99 @@ +// file      : frontend-elements/token-stream.hxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef FRONTEND_ELEMENTS_TOKEN_STREAM_HXX +#define FRONTEND_ELEMENTS_TOKEN_STREAM_HXX + +#include <frontend-elements/types.hxx> + +#include <string>   // std::char_traits +#include <istream> + +namespace FrontendElements +{ +  // +  // +  template <typename Token> +  class TokenStream +  { +  public: +    virtual +    ~TokenStream () +    { +    } + +  public: +    virtual Token +    next () = 0; +  }; + + +  // +  // +  template <> +  class TokenStream<Char> +  { +  public: +    typedef +    std::char_traits<FrontendElements::Char> +    Traits; + +    typedef +    Traits::int_type +    AsInt; + +    typedef +    Traits::char_type +    AsChar; + +  public: +    virtual +    ~TokenStream () +    { +    } + +  public: +    virtual AsInt +    next () = 0; + +    static AsChar +    to_char (AsInt i) +    { +      return Traits::to_char_type (i); +    } + +    static AsInt +    eos () +    { +      return Traits::eof (); +    } +  }; + +  class InputStreamAdapter: public TokenStream<Char> +  { +  public: +    virtual +    ~InputStreamAdapter () +    { +    } + +    InputStreamAdapter (std::istream& is) +        : is_ (is) +    { +    } + +  public: +    virtual AsInt +    next () +    { +      return is_.get (); +    } + +  private: +    std::istream& is_; +  }; +} + +#endif  // FRONTEND_ELEMENTS_TOKEN_STREAM_HXX diff --git a/libfrontend-elements/frontend-elements/traversal.cxx b/libfrontend-elements/frontend-elements/traversal.cxx new file mode 100644 index 0000000..079a2a8 --- /dev/null +++ b/libfrontend-elements/frontend-elements/traversal.cxx @@ -0,0 +1,10 @@ +// file      : frontend-elements/traversal.cxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <frontend-elements/traversal.hxx> + +namespace FrontendElements +{ +} diff --git a/libfrontend-elements/frontend-elements/traversal.hxx b/libfrontend-elements/frontend-elements/traversal.hxx new file mode 100644 index 0000000..b320484 --- /dev/null +++ b/libfrontend-elements/frontend-elements/traversal.hxx @@ -0,0 +1,293 @@ +// file      : frontend-elements/traversal.hxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef FRONTEND_ELEMENTS_TRAVERSAL_HXX +#define FRONTEND_ELEMENTS_TRAVERSAL_HXX + +#include <frontend-elements/types.hxx> + +#include <cult/containers/map.hxx> +#include <cult/containers/set.hxx> +#include <cult/containers/vector.hxx> + +#include <cult/rtti/type-info.hxx> + +#include <cult/trace/stream.hxx> + +//@@ Move to trace next time you are about to uncomment this. +// +// #include <iostream> +// using std::wcerr; +// using std::endl; + + +namespace FrontendElements +{ +  namespace Traversal +  { +    // +    // +    template<typename X> +    class TraverserBase +    { +    protected: +      virtual +      ~TraverserBase (); + +      virtual Void +      trampoline (X&) = 0; + +      virtual Void +      trampoline (X const&) = 0; + +      template <typename> +      friend class DispatcherBase; +    }; + + +    // +    // +    template <typename X> +    class DispatcherBase +    { +      typedef +      Cult::RTTI::TypeId +      TypeId; + +      typedef +      Cult::RTTI::TypeInfo +      TypeInfo; + +    public: +      virtual +      ~DispatcherBase (); + +      virtual Void +      dispatch (X&); + +      virtual Void +      dispatch (X const&); + +      Void +      map (TypeId id, TraverserBase<X>& t) +      { +        //wcerr << "map for " << id.name () << " to " << &t +	//      << " in " << &traversal_map_ << endl; + +        Traversers& traversers (traversal_map_[id]); +        traversers.push_back (&t); +      } + +    public: +      typedef +      Cult::Containers::Vector<TraverserBase<X>*> +      Traversers; + +      typedef +      Cult::Containers::Map<TypeId, Traversers> +      TraversalMap; + +      typedef +      typename TraversalMap::ConstIterator +      Iterator; + +      Iterator +      begin () const +      { +        return traversal_map_.begin (); +      } + +      Iterator +      end () const +      { +        return traversal_map_.end (); +      } + +    protected: +      static Cult::Trace::Stream tout; + +    private: +      template<typename Y> +      Void +      dispatch_ (Y&); + +    private: + +      struct TypeInfoComparator +      { +        Boolean +        operator () (TypeInfo const& a, TypeInfo const& b) const +        { +          return a.type_id () < b.type_id (); +        } +      }; + +      typedef +      Cult::Containers::Map<TypeInfo, UnsignedLong, TypeInfoComparator> +      LevelMap; + +      typedef +      Cult::Containers::Set<TypeInfo, TypeInfoComparator> +      TypeInfoSet; + +      static UnsignedLong +      compute_levels (TypeInfo const& ti, UnsignedLong cur, LevelMap& map); + +      static Void +      flatten_tree (TypeInfo const& ti, TypeInfoSet& set); + +    private: +      TraversalMap traversal_map_; +    }; + + +    // +    // +    template <typename X> +    class Dispatcher: public virtual DispatcherBase<X> +    { +    public: +      Dispatcher () +          : merge_ (true) +      { +      } + +      Void +      traverser (DispatcherBase<X>& d) +      { +        for (typename DispatcherBase<X>::Iterator +               i (d.begin ()), e (d.end ()); i != e; ++i) +        { +          for (typename DispatcherBase<X>::Traversers::ConstIterator +                 t (i->second.begin ()), e (i->second.end ()); t != e; ++t) +          { +            dispatcher_.map (i->first, **t); +          } +        } +      } + +    public: +      virtual Void +      dispatch (X& x) +      { +        merge (); +        dispatcher_.dispatch (x); +      } + +      virtual Void +      dispatch (X const& x) +      { +        merge (); +        dispatcher_.dispatch (x); +      } + +      using DispatcherBase<X>::begin; +      using DispatcherBase<X>::end; + +    private: +      Void +      merge () +      { +        if (merge_) +        { +          for (typename DispatcherBase<X>::Iterator +                 i (begin ()), e (end ()); i != e; ++i) +          { +            for (typename DispatcherBase<X>::Traversers::ConstIterator +                   t (i->second.begin ()), e (i->second.end ()); t != e; ++t) +            { +              dispatcher_.map (i->first, **t); +            } +          } + +          merge_ = false; +        } +      } + +    protected: +      template <typename I, typename Y> +      Void +      iterate_and_dispatch (I begin, I end, DispatcherBase<Y>& d) +      { +        for (; begin != end; ++begin) +        { +          d.dispatch (*begin); +        } +      } + +      template <typename T, typename A, typename I, typename Y> +      Void +      iterate_and_dispatch (I begin, +                            I end, +                            DispatcherBase<Y>& d, +                            T& t, +                            Void (T::*next)(A&), +                            A& a) +      { +        for (; begin != end;) +        { +          d.dispatch (*begin); + +          if (++begin != end && next != 0) +            (t.*next) (a); +        } +      } + +    private: +      Boolean merge_; +      DispatcherBase<X> dispatcher_; +    }; + + +    // +    // +    template <typename T, typename X> +    struct Traverser : TraverserBase<X>, virtual Dispatcher<X> +    { +      typedef T Type; + +      Traverser () +      { +        map (typeid (Type), *this); +      } + +      virtual Void +      traverse (Type&) +      { +        abort (); +      } + +      virtual Void +      traverse (Type const&) +      { +        abort (); +      } + +    protected: +      virtual Void +      trampoline (X& x) +      { +        //wcerr << "trampoline for " << &i << " to type " +        //      << typeid (type).name () << endl; + +        traverse (dynamic_cast<Type&> (x)); +      } + +      virtual Void +      trampoline (X const& x) +      { +        //wcerr << "trampoline for " << &i << " to type " +        //      << typeid (Type).name () << endl; + +        traverse (dynamic_cast<Type const&> (x)); +      } +    }; +  } +} + +#include <frontend-elements/traversal.ixx> +#include <frontend-elements/traversal.txx> + +#endif  // FRONTEND_ELEMENTS_TRAVERSAL_HXX diff --git a/libfrontend-elements/frontend-elements/traversal.ixx b/libfrontend-elements/frontend-elements/traversal.ixx new file mode 100644 index 0000000..47c7314 --- /dev/null +++ b/libfrontend-elements/frontend-elements/traversal.ixx @@ -0,0 +1,8 @@ +// file      : frontend-elements/traversal.ixx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace FrontendElements +{ +} diff --git a/libfrontend-elements/frontend-elements/traversal.txx b/libfrontend-elements/frontend-elements/traversal.txx new file mode 100644 index 0000000..6e6bfa3 --- /dev/null +++ b/libfrontend-elements/frontend-elements/traversal.txx @@ -0,0 +1,135 @@ +// file      : frontend-elements/traversal.txx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace FrontendElements +{ +  namespace Traversal +  { +    // TraverserBase +    // + +    template<typename X> +    TraverserBase<X>:: +    ~TraverserBase () +    { +    } + +    // DispatcherBase +    // + +    template <typename X> +    DispatcherBase<X>:: +    ~DispatcherBase () +    { +    } + +    template <typename X> +    Void DispatcherBase<X>:: +    dispatch (X& x) +    { +      dispatch_ (x); +    } + +    template <typename X> +    void DispatcherBase<X>:: +    dispatch (X const& x) +    { +      dispatch_ (x); +    } + +    template <typename X> +    template <typename Y> +    void DispatcherBase<X>:: +    dispatch_ (Y& y) +    { +      LevelMap levels; + +      TypeInfo const& ti (Cult::RTTI::lookup (typeid (y))); + +      UnsignedLong max (compute_levels (ti, 0, levels)); + +      tout << "starting dispatch process for " << ti.type_id ().name () +           << " with " << max << " levels"; + +      for (UnsignedLong l (0); l < max + 1; ++l) +      { +        TypeInfoSet dispatched; + +        for (typename LevelMap::ConstIterator +               i (levels.begin ()), e (levels.end ()); i != e; ++i) +        { +          if (i->second == l) +          { +            typename TraversalMap::ConstIterator v ( +              traversal_map_.find (i->first.type_id ())); + +            if (v != traversal_map_.end ()) +            { +              tout << "dispatching traversers for " << ti.type_id ().name () +                   << " as " << i->first.type_id ().name (); + +              Traversers const& traversers (v->second); + +              for (typename Traversers::ConstIterator +                     ti (traversers.begin ()), te (traversers.end ()); ti != te; ++ti) +              { +                (*ti)->trampoline (y); +              } + +              flatten_tree (i->first, dispatched); +            } +          } +        } + +        // Remove traversed types from the level map. +        // +        for (typename TypeInfoSet::ConstIterator i (dispatched.begin ()); +             i != dispatched.end (); ++i) +        { +          levels.erase (*i); +        } +      } +    } + + +    template <typename X> +    UnsignedLong DispatcherBase<X>:: +    compute_levels (TypeInfo const& ti, UnsignedLong cur, LevelMap& map) +    { +      UnsignedLong ret (cur); + +      if (map.find (ti) == map.end () || map[ti] < cur) map[ti] = cur; + +      for (TypeInfo::BaseIterator i (ti.begin_base ()); +           i != ti.end_base (); ++i) +      { +        UnsignedLong tmp (compute_levels (i->type_info (), cur + 1, map)); + +        if (tmp > ret) +          ret = tmp; +      } + +      return ret; +    } + +    template <typename X> +    Void DispatcherBase<X>:: +    flatten_tree (TypeInfo const& ti, TypeInfoSet& set) +    { +      set.insert (ti); + +      for (TypeInfo::BaseIterator i = ti.begin_base (); +           i != ti.end_base (); ++i) +      { +        flatten_tree (i->type_info (), set); +      } +    } + +    template <typename X> +    Cult::Trace::Stream DispatcherBase<X>:: +    tout ("frontend-elements::traversal", 5); +  } +} + diff --git a/libfrontend-elements/frontend-elements/types.hxx b/libfrontend-elements/frontend-elements/types.hxx new file mode 100644 index 0000000..f9a6905 --- /dev/null +++ b/libfrontend-elements/frontend-elements/types.hxx @@ -0,0 +1,16 @@ +// file      : frontend-elements/types.hxx +// author    : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef FRONTEND_ELEMENTS_TYPES_HXX +#define FRONTEND_ELEMENTS_TYPES_HXX + +#include <cult/types.hxx> + +namespace FrontendElements +{ +  using namespace Cult::Types; +} + +#endif  // FRONTEND_ELEMENTS_TYPES_HXX diff --git a/libfrontend-elements/makefile b/libfrontend-elements/makefile new file mode 100644 index 0000000..99af2f9 --- /dev/null +++ b/libfrontend-elements/makefile @@ -0,0 +1,15 @@ +# file      : makefile +# author    : Boris Kolpackov <boris@kolpackov.net> +# copyright : Copyright (c) 2005-2010 Boris Kolpackov +# license   : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))build/bootstrap.make + +default   := $(out_base)/ +clean     := $(out_base)/.clean + +$(default): $(out_base)/frontend-elements/ $(out_base)/examples/ +$(clean): $(out_base)/frontend-elements/.clean $(out_base)/examples/.clean + +$(call import,$(src_base)/frontend-elements/makefile) +$(call import,$(src_base)/examples/makefile) diff --git a/libfrontend-elements/version b/libfrontend-elements/version new file mode 100644 index 0000000..65087b4 --- /dev/null +++ b/libfrontend-elements/version @@ -0,0 +1 @@ +1.1.4 | 
