summaryrefslogtreecommitdiff
path: root/libbackend-elements
diff options
context:
space:
mode:
Diffstat (limited to 'libbackend-elements')
-rw-r--r--libbackend-elements/GPLv2340
-rw-r--r--libbackend-elements/INSTALL26
-rw-r--r--libbackend-elements/LICENSE25
-rw-r--r--libbackend-elements/NEWS91
-rw-r--r--libbackend-elements/README14
-rw-r--r--libbackend-elements/backend-elements/indentation/buffer.hxx61
-rw-r--r--libbackend-elements/backend-elements/indentation/buffer.txx12
-rw-r--r--libbackend-elements/backend-elements/indentation/clip.hxx173
-rw-r--r--libbackend-elements/backend-elements/indentation/clip.txx12
-rw-r--r--libbackend-elements/backend-elements/indentation/cxx.hxx1016
-rw-r--r--libbackend-elements/backend-elements/indentation/cxx.txx12
-rw-r--r--libbackend-elements/backend-elements/indentation/idl.hxx290
-rw-r--r--libbackend-elements/backend-elements/indentation/idl.txx11
-rw-r--r--libbackend-elements/backend-elements/indentation/sloc.hxx277
-rw-r--r--libbackend-elements/backend-elements/makefile63
-rw-r--r--libbackend-elements/backend-elements/regex.hxx208
-rw-r--r--libbackend-elements/backend-elements/regex.txx52
-rw-r--r--libbackend-elements/backend-elements/types.hxx16
-rw-r--r--libbackend-elements/build/bootstrap.make46
-rw-r--r--libbackend-elements/build/cxx/configuration-dynamic.make14
-rw-r--r--libbackend-elements/build/cxx/gnu/configuration-dynamic.make8
-rw-r--r--libbackend-elements/build/export/libbackend-elements/stub.make13
l---------libbackend-elements/build/import/libbackend-elements/LICENSE1
-rw-r--r--libbackend-elements/build/import/libbackend-elements/configuration-rules.make15
-rwxr-xr-xlibbackend-elements/build/import/libbackend-elements/configure55
-rw-r--r--libbackend-elements/build/import/libbackend-elements/stub.make32
-rw-r--r--libbackend-elements/build/import/libboost/LICENSE340
-rw-r--r--libbackend-elements/build/import/libboost/configuration-dynamic.make8
-rw-r--r--libbackend-elements/build/import/libboost/configuration-rules.make15
-rwxr-xr-xlibbackend-elements/build/import/libboost/configure65
-rw-r--r--libbackend-elements/build/import/libboost/regex/rules.make38
-rw-r--r--libbackend-elements/build/import/libboost/regex/stub.make32
-rw-r--r--libbackend-elements/build/import/libboost/version1
-rw-r--r--libbackend-elements/build/import/libcult/LICENSE340
-rw-r--r--libbackend-elements/build/import/libcult/configuration-dynamic.make4
-rw-r--r--libbackend-elements/build/import/libcult/configuration-rules.make15
-rwxr-xr-xlibbackend-elements/build/import/libcult/configure55
-rw-r--r--libbackend-elements/build/import/libcult/stub.make30
-rw-r--r--libbackend-elements/build/ld/configuration-lib-dynamic.make13
-rw-r--r--libbackend-elements/documentation/BUGS1
-rw-r--r--libbackend-elements/documentation/TODO1
-rw-r--r--libbackend-elements/documentation/default.css160
-rw-r--r--libbackend-elements/documentation/index.xhtml56
-rw-r--r--libbackend-elements/makefile17
-rw-r--r--libbackend-elements/tests/indentation/cxx/driver.cxx105
-rw-r--r--libbackend-elements/tests/indentation/cxx/makefile57
-rw-r--r--libbackend-elements/tests/indentation/cxx/output.cxx75
-rw-r--r--libbackend-elements/tests/indentation/makefile18
-rw-r--r--libbackend-elements/tests/makefile18
-rw-r--r--libbackend-elements/version1
50 files changed, 4348 insertions, 0 deletions
diff --git a/libbackend-elements/GPLv2 b/libbackend-elements/GPLv2
new file mode 100644
index 0000000..3912109
--- /dev/null
+++ b/libbackend-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/libbackend-elements/INSTALL b/libbackend-elements/INSTALL
new file mode 100644
index 0000000..71f9f4a
--- /dev/null
+++ b/libbackend-elements/INSTALL
@@ -0,0 +1,26 @@
+Prerequisites
+
+ build-time:
+
+ - build >= 0.3.2 http://kolpackov.net/projects/build/
+ - g++ >= 3.4.3 http://gcc.gnu.org
+
+ run-time:
+
+ - libcult >= 1.4.1 http://kolpackov.net/projects/libcult/
+ - libboost_regex >= 1.33.1 http://boost.org
+
+
+Building libbackend-elements
+
+ To build in the source directory simply say `make'. You can also
+ build in a separate directory, e.g.,
+
+ $ mkdir libbackend-elements-i686-pc-linux-gnu
+ $ cd libbackend-elements-i686-pc-linux-gnu
+ $ make -f ../libbackend-elements-x.y.z/makefile
+
+
+Installing libbackend-elements
+
+ Not supported in this version.
diff --git a/libbackend-elements/LICENSE b/libbackend-elements/LICENSE
new file mode 100644
index 0000000..3204be4
--- /dev/null
+++ b/libbackend-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/libbackend-elements/NEWS b/libbackend-elements/NEWS
new file mode 100644
index 0000000..6e1c5b9
--- /dev/null
+++ b/libbackend-elements/NEWS
@@ -0,0 +1,91 @@
+Version 1.7.2
+
+ * Fix a bug in C++ indenter.
+
+ * Add support for libbackend-elements bundling.
+
+ * New boost import stub.
+
+Version 1.7.1
+
+ * 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.7.0
+
+ * Support for the '} foo_;' construct in the C++ indenter.
+
+Version 1.6.1
+
+ * Fixed a bug in import stubs.
+
+ * Got rid of warnings reported by g++-4.3.
+
+Version 1.6.0
+
+ * New Regex::Pattern class that represents a regex pattern (without
+ substitution, unlike Regex::Expression).
+
+ * Removed Regex::perl_s functions. Use the Regex::Expression class
+ which provides extended functionality and better error handling.
+
+Version 1.5.0
+
+ * New regex class.
+
+ * Upgraded to the new boost import stub.
+
+Version 1.4.1
+
+ * Upgraded to the new boost import stub.
+
+Version 1.4.0
+
+ * Support for the do-while construct in the C++ indenter.
+
+Version 1.3.0
+
+ * Support for the C-style comments in the C++ indenter.
+
+Version 1.2.0
+
+ * Upgraded to build-0.3.0.
+
+Version 1.1.0
+
+ * Numerous improvements to the C++ indenter. In particular, it
+ now can properly indent single-line blocks after if, else, etc.
+ as well as suppress new lines between }else, }case, and }catch.
+ It was also optimized for speed.
+
+ * Added a test for the C++ indenter.
+
+
+Version 1.0.4
+
+ * Upgraded to the version-aware libboost import stub.
+
+
+Version 1.0.3
+
+ * Upgraded to build-0.2.0.
+
+ * C++ auto-indenter has been improved to recognize and ignore beginnings
+ of string literals (") and character literals (') in C++-style comments.
+
+
+Version 1.0.2
+
+ * C++ auto-indenter has been improved to support function argument
+ indentation. Both "same-line" and "new-line" styles are supported.
+
+
+Version 1.0.1
+
+ * Build system improvements.
+
+
+Version 1.0.0
+
+ * First public release.
diff --git a/libbackend-elements/README b/libbackend-elements/README
new file mode 100644
index 0000000..42bf3d8
--- /dev/null
+++ b/libbackend-elements/README
@@ -0,0 +1,14 @@
+libbackend_elements is a collection of elementary building for
+implementing compiler backends 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/libbackend-elements/backend-elements/indentation/buffer.hxx b/libbackend-elements/backend-elements/indentation/buffer.hxx
new file mode 100644
index 0000000..7058814
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/buffer.hxx
@@ -0,0 +1,61 @@
+// file : backend-elements/indentation/buffer.hxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BACKEND_ELEMENTS_INDENTATION_BUFFER_HXX
+#define BACKEND_ELEMENTS_INDENTATION_BUFFER_HXX
+
+#include <backend-elements/types.hxx>
+
+#include <string>
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ template <typename C>
+ class Buffer: public NonCopyable
+ {
+ public:
+ struct Write {};
+
+ public:
+ virtual
+ ~Buffer ()
+ {
+ }
+
+ public:
+ typedef
+ std::char_traits<C>
+ Traits;
+
+ typedef
+ typename Traits::char_type
+ AsChar;
+
+ typedef
+ typename Traits::int_type
+ AsInt;
+
+ public:
+ virtual AsInt
+ put (AsChar c) = 0;
+
+ // Unbuffer flushes internal formatting buffers (if any).
+ // Note that unbuffer is not exactly flushing since it can
+ // result in formatting errors and in general can not be
+ // called at arbitrary points. Natural use case would be
+ // to call unbuffer at the end of the stream when no more
+ // data is expected.
+ //
+ virtual Void
+ unbuffer () = 0;
+ };
+ }
+}
+
+#include <backend-elements/indentation/buffer.txx>
+
+#endif // BACKEND_ELEMENTS_INDENTATION_BUFFER_HXX
diff --git a/libbackend-elements/backend-elements/indentation/buffer.txx b/libbackend-elements/backend-elements/indentation/buffer.txx
new file mode 100644
index 0000000..57ba7ab
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/buffer.txx
@@ -0,0 +1,12 @@
+// file : backend-elements/indentation/buffer.txx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ }
+}
+
diff --git a/libbackend-elements/backend-elements/indentation/clip.hxx b/libbackend-elements/backend-elements/indentation/clip.hxx
new file mode 100644
index 0000000..068ed0d
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/clip.hxx
@@ -0,0 +1,173 @@
+// file : backend-elements/indentation/clip.hxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BACKEND_ELEMENTS_INDENTATION_CLIP_HXX
+#define BACKEND_ELEMENTS_INDENTATION_CLIP_HXX
+
+#include <backend-elements/types.hxx>
+
+#include <backend-elements/indentation/buffer.hxx>
+
+#include <ostream>
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ template <typename C>
+ class ToStreambufAdapter: public std::basic_streambuf<C>,
+ public NonCopyable
+ {
+ public:
+ typedef
+ typename std::basic_streambuf<C>::traits_type
+ Traits;
+
+ typedef
+ typename std::basic_streambuf<C>::char_type
+ AsChar;
+
+ typedef
+ typename std::basic_streambuf<C>::int_type
+ AsInt;
+
+ public:
+ ToStreambufAdapter (Buffer<C>& buffer)
+ : buffer_ (buffer)
+ {
+ }
+
+ virtual AsInt
+ overflow (AsInt ch)
+ {
+ return buffer_.put (Traits::to_char_type (ch));
+ }
+
+ virtual Int
+ sync ()
+ {
+ return 0;
+ }
+
+ private:
+ Buffer<C>& buffer_;
+ };
+
+
+ template <typename C>
+ class FromStreambufAdapter: public Buffer<C>
+ {
+ public:
+ typedef
+ typename Buffer<C>::Traits
+ Traits;
+
+ typedef
+ typename Buffer<C>::AsChar
+ AsChar;
+
+ typedef
+ typename Buffer<C>::AsInt
+ AsInt;
+
+ typedef
+ typename Buffer<C>::Write
+ Write;
+
+ public:
+ FromStreambufAdapter (std::basic_streambuf<C>& b)
+ : buffer_ (b)
+ {
+ }
+
+ virtual AsInt
+ put (AsChar ch)
+ {
+ return buffer_.sputc (ch);
+ }
+
+ virtual Void
+ unbuffer ()
+ {
+ try
+ {
+ if (buffer_.pubsync () == 0) return;
+ }
+ catch (std::ios_base::failure const&)
+ {
+ }
+
+ throw Write ();
+ }
+
+ private:
+ std::basic_streambuf<C>& buffer_;
+ };
+
+
+ template <template <typename> class Buffer, typename C = Char>
+ class Clip: public NonCopyable
+ {
+ public:
+ Clip (std::basic_ostream<C>& os)
+ : os_ (os),
+ prev_ (os_.rdbuf ()),
+ from_adapter_ (*prev_),
+ buffer_ (from_adapter_),
+ to_adapter_ (buffer_)
+ {
+ os_.rdbuf (&to_adapter_);
+ }
+
+ /*
+ template <typename Arg0>
+ Clip (std::basic_ostream<C>& os, Arg0 a0)
+ : os_ (os),
+ prev_ (os_.rdbuf ()),
+ from_adapter_ (*prev_),
+ buffer_ (from_adapter_, a0),
+ to_adapter_ (buffer_)
+ {
+ os_.rdbuf (&to_adapter_);
+ }
+ */
+
+ ~Clip ()
+ {
+ try
+ {
+ buffer_.unbuffer ();
+ }
+ catch (...)
+ {
+ os_.rdbuf (prev_);
+ throw;
+ }
+
+ os_.rdbuf (prev_);
+ }
+
+ Buffer<C>&
+ buffer ()
+ {
+ return buffer_;
+ }
+
+ private:
+ std::basic_ostream<C>& os_;
+ std::basic_streambuf<C>* prev_;
+
+ FromStreambufAdapter<C> from_adapter_;
+
+ Buffer<C> buffer_;
+
+ ToStreambufAdapter<C> to_adapter_;
+ };
+ }
+}
+
+#include <backend-elements/indentation/clip.txx>
+
+#endif // BACKEND_ELEMENTS_INDENTATION_CLIP_HXX
diff --git a/libbackend-elements/backend-elements/indentation/clip.txx b/libbackend-elements/backend-elements/indentation/clip.txx
new file mode 100644
index 0000000..58112f1
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/clip.txx
@@ -0,0 +1,12 @@
+// file : backend-elements/indentation/clip.txx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ }
+}
+
diff --git a/libbackend-elements/backend-elements/indentation/cxx.hxx b/libbackend-elements/backend-elements/indentation/cxx.hxx
new file mode 100644
index 0000000..f10341a
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/cxx.hxx
@@ -0,0 +1,1016 @@
+// file : backend-elements/indentation/cxx.hxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BACKEND_ELEMENTS_INDENTATION_CXX_HXX
+#define BACKEND_ELEMENTS_INDENTATION_CXX_HXX
+
+#include <backend-elements/types.hxx>
+#include <backend-elements/indentation/buffer.hxx>
+
+#include <cult/containers/set.hxx>
+#include <cult/containers/stack.hxx>
+#include <cult/containers/deque.hxx>
+
+#include <locale>
+
+// #include <iostream> // @@ tmp
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ template <typename C>
+ class CXX: public Buffer<C>/*, public NonCopyable*/
+ {
+ public:
+ typedef
+ typename Buffer<C>::Traits
+ Traits;
+
+ typedef
+ typename Buffer<C>::AsChar
+ AsChar;
+
+ typedef
+ typename Buffer<C>::AsInt
+ AsInt;
+
+ typedef
+ typename Buffer<C>::Write
+ Write;
+
+ public:
+ CXX (Buffer<C>& out)
+ : out_ (out),
+ buffering_ (false),
+ position_ (0),
+ paren_balance_ (0),
+ spaces_ (2),
+ construct_ (Construct::other),
+ lbrace_ ("{"),
+ rbrace_ ("}")
+ // locale_ ("C")
+ {
+ indentation_.push (0);
+
+ single_line_blocks_.insert ("if");
+ single_line_blocks_.insert ("do");
+ single_line_blocks_.insert ("for");
+ single_line_blocks_.insert ("else");
+ single_line_blocks_.insert ("case");
+ single_line_blocks_.insert ("while");
+
+ follow_blocks_.insert ("else");
+ follow_blocks_.insert ("case");
+ follow_blocks_.insert ("catch");
+ follow_blocks_.insert ("default");
+ }
+
+ public:
+ virtual AsInt
+ put (AsChar c)
+ {
+ AsInt result (Traits::to_int_type (c));
+
+ try
+ {
+ // First determine what kind of construct we are in.
+ //
+ typename Construct::Value new_construct (construct_);
+ typename Construct::Value old_construct (construct_);
+
+ switch (c)
+ {
+ case '\n':
+ {
+ if (construct_ == Construct::pp_directive ||
+ construct_ == Construct::cxx_comment)
+ construct_ = new_construct = Construct::other;
+
+ break;
+ }
+ case '#':
+ {
+ if (construct_ == Construct::other)
+ construct_ = new_construct = Construct::pp_directive;
+
+ break;
+ }
+ case '\"':
+ {
+ if (construct_ != Construct::pp_directive &&
+ construct_ != Construct::c_comment &&
+ construct_ != Construct::cxx_comment &&
+ construct_ != Construct::char_literal)
+ {
+ // We might be in an escape sequence.
+ //
+ Boolean es (!hold_.empty () && hold_.back () == '\\');
+
+ if (es)
+ {
+ // Scan the hold sequence backwards to figure out if this
+ // backslash is part of this escape sequence or a preceding
+ // one.
+ //
+ for (typename Hold::ReverseIterator i (hold_.rbegin () + 1),
+ e (hold_.rend ()); i != e && *i == '\\'; ++i)
+ es = !es;
+ }
+
+ if (!es)
+ {
+ // Not an escape sequence.
+ //
+ if (construct_ == Construct::string_literal)
+ new_construct = Construct::other;
+ else
+ construct_ = new_construct = Construct::string_literal;
+ }
+ }
+
+ break;
+ }
+ case '\'':
+ {
+ if (construct_ != Construct::pp_directive &&
+ construct_ != Construct::c_comment &&
+ construct_ != Construct::cxx_comment &&
+ construct_ != Construct::string_literal)
+ {
+ // We might be in an escape sequence.
+ //
+ Boolean es (!hold_.empty () && hold_.back () == '\\');
+
+ if (es)
+ {
+ // Scan the hold sequence backwards to figure out if this
+ // backslash is part of this escape sequence or a preceding
+ // one.
+ //
+ for (typename Hold::ReverseIterator i (hold_.rbegin () + 1),
+ e (hold_.rend ()); i != e && *i == '\\'; ++i)
+ es = !es;
+ }
+
+ if (!es)
+ {
+ if (construct_ == Construct::char_literal)
+ new_construct = Construct::other;
+ else
+ construct_ = new_construct = Construct::char_literal;
+ }
+ }
+
+ break;
+ }
+ case '/':
+ {
+ if (construct_ == Construct::other)
+ {
+ if (!hold_.empty () && hold_.back () == '/')
+ construct_ = new_construct = Construct::cxx_comment;
+ }
+
+ if (construct_ == Construct::c_comment)
+ {
+ if (!hold_.empty () && hold_.back () == '*')
+ construct_ = new_construct = Construct::other;
+ }
+
+ break;
+ }
+ case '*':
+ {
+ if (construct_ == Construct::other)
+ {
+ if (!hold_.empty () && hold_.back () == '/')
+ construct_ = new_construct = Construct::c_comment;
+ }
+
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ // Special handling of CPP directives.
+ //
+ if (construct_ == Construct::pp_directive)
+ {
+ result = write (c);
+ position_++;
+ return result;
+ }
+
+ //
+ //
+ tokenize (c, old_construct);
+
+
+ // Indentation in parenthesis. We don't need to make sure
+ // we are not in a comments, etc. because we make sure we
+ // don't hold anything in those states.
+ //
+ if (!hold_.empty () && hold_.back () == '(')
+ {
+ unbuffer (); // We don't need to hold it anymore.
+
+ if (c == '\n')
+ indentation_.push (indentation_.top () + spaces_);
+ else
+ indentation_.push (position_);
+ }
+
+
+ //
+ //
+ Boolean defaulting (false);
+
+ switch (c)
+ {
+ case '\n':
+ {
+ if (!indent_block_.empty () && construct_ == Construct::other)
+ indent_block_.top ().newline_ = true;
+
+ hold_.push_back (c);
+ position_ = 0; // Starting a new line.
+
+ break;
+ }
+ case '{':
+ {
+ if (construct_ == Construct::other)
+ {
+ if (!indent_block_.empty ())
+ {
+ // Pop all the blocks until the one that was indented.
+ //
+ while (!indent_block_.top ().indented_)
+ indent_block_.pop ();
+
+ if (indentation_.size () > 1)
+ indentation_.pop ();
+
+ indent_block_.pop ();
+ }
+
+ ensure_new_line ();
+ output_indentation ();
+ result = write (c);
+ ensure_new_line ();
+
+ indentation_.push (indentation_.top () + spaces_);
+ }
+ else
+ defaulting = true;
+
+ break;
+ }
+ case '}':
+ {
+ if (construct_ == Construct::other)
+ {
+ if (indentation_.size () > 1)
+ indentation_.pop ();
+
+ // Reduce multiple newlines to one.
+ //
+ while (hold_.size () > 1)
+ {
+ typename Hold::ReverseIterator i (hold_.rbegin ());
+
+ if (*i == '\n' && *(i + 1) == '\n')
+ hold_.pop_back ();
+ else
+ break;
+ }
+
+ ensure_new_line ();
+ output_indentation ();
+
+ hold_.push_back (c);
+
+
+ // Add double newline after '}'.
+ //
+ hold_.push_back ('\n');
+ hold_.push_back ('\n');
+ position_ = 0;
+
+ buffering_ = true;
+ }
+ else
+ defaulting = true;
+
+ break;
+ }
+ case ';':
+ {
+ if (construct_ == Construct::other)
+ {
+ // for (;;)
+ //
+ if (!indent_block_.empty () && paren_balance_ == 0)
+ {
+ // Pop all the blocks until the one that was indented.
+ //
+ while (!indent_block_.top ().indented_)
+ indent_block_.pop ();
+
+ if (indentation_.size () > 1)
+ indentation_.pop ();
+
+ indent_block_.pop ();
+ }
+
+ if (paren_balance_ != 0)
+ {
+ // We are inside for (;;) statement. Nothing to do here.
+ //
+ defaulting = true;
+ }
+ else
+ {
+ // Handling '};' case.
+ //
+
+ Boolean brace (false);
+
+ if (hold_.size () > 1 && hold_.back () == '\n')
+ {
+ Boolean pop_nl (false);
+
+ for (typename Hold::ReverseIterator
+ i (hold_.rbegin ()), e (hold_.rend ());
+ i != e; ++i)
+ {
+ if (*i != '\n')
+ {
+ if (*i == '}')
+ brace = pop_nl = true;
+
+ break;
+ }
+ }
+
+ if (pop_nl)
+ while (hold_.back () == '\n')
+ hold_.pop_back ();
+ }
+
+ output_indentation ();
+ result = write (c);
+ position_++;
+
+ if (brace)
+ {
+ hold_.push_back ('\n');
+ hold_.push_back ('\n');
+ }
+
+ ensure_new_line ();
+ }
+ }
+ else
+ defaulting = true;
+
+ break;
+ }
+ case ' ':
+ {
+ if (construct_ == Construct::other)
+ {
+ // Handling '} foo_;' case.
+ //
+ if (hold_.size () > 1 && hold_.back () == '\n')
+ {
+ Boolean pop_nl (false);
+
+ for (typename Hold::ReverseIterator
+ i (hold_.rbegin ()), e (hold_.rend ());
+ i != e; ++i)
+ {
+ if (*i != '\n')
+ {
+ if (*i == '}')
+ pop_nl = true;
+
+ break;
+ }
+ }
+
+ if (pop_nl)
+ while (hold_.back () == '\n')
+ hold_.pop_back ();
+ }
+ }
+
+ defaulting = true;
+ break;
+ }
+ case '\\':
+ {
+ if (construct_ != Construct::pp_directive &&
+ construct_ != Construct::c_comment &&
+ construct_ != Construct::cxx_comment)
+ {
+ output_indentation ();
+ hold_.push_back (c);
+ position_++;
+ }
+ else
+ defaulting = true;
+
+ break;
+
+ }
+ case '(':
+ {
+ if (construct_ == Construct::other)
+ {
+ // Hold it so that we can see what's coming next.
+ //
+ output_indentation ();
+ hold_.push_back (c);
+ position_++;
+ paren_balance_++;
+ }
+ else
+ defaulting = true;
+ break;
+ }
+ case ')':
+ {
+ if (construct_ == Construct::other)
+ {
+ if (indentation_.size () > 1)
+ indentation_.pop ();
+
+ if (paren_balance_ > 0)
+ paren_balance_--;
+ }
+
+ defaulting = true;
+ break;
+ }
+ case '/':
+ {
+ if (construct_ == Construct::other)
+ {
+ output_indentation ();
+ hold_.push_back (c);
+ position_++;
+ }
+ else
+ defaulting = true;
+
+ break;
+ }
+ case '*':
+ {
+ if (construct_ == Construct::c_comment)
+ {
+ output_indentation ();
+ hold_.push_back (c);
+ position_++;
+ }
+ else
+ defaulting = true;
+
+ break;
+ }
+ default:
+ {
+ defaulting = true;
+ break;
+ }
+ }
+
+
+ if (defaulting)
+ {
+ output_indentation ();
+ result = write (c);
+ position_++;
+ }
+
+ construct_ = new_construct;
+ }
+ catch (Write const&)
+ {
+ result = Traits::eof ();
+ }
+
+ return result;
+ }
+
+ private:
+ typedef Cult::StringTemplate<C> String;
+
+ Void
+ next_token (String const& old, AsChar c)
+ {
+ //std::cerr << "next token: " << token_
+ // << "; old token: " << old << std::endl;
+
+ // Handle one line indentation blocks (if, else, etc).
+ //
+ if (single_line_blocks_.find (token_) != single_line_blocks_.end ())
+ {
+ // Only indent sub-blocks if we are on a new line.
+ //
+ Boolean indent (indent_block_.empty () ||
+ indent_block_.top ().newline_);
+
+ indent_block_.push (IndentBlockInfo (c == '\n', indent));
+
+ if (indent)
+ indentation_.push (indentation_.top () + spaces_);
+ }
+
+ // Keep track of the do ... while construct in order to suppress
+ // the newline after } and before while.
+ //
+ if (old == String ("do") && token_ == lbrace_)
+ {
+ do_while_state_.push (0);
+ }
+
+ if (!do_while_state_.empty ())
+ {
+ if (token_ == lbrace_)
+ do_while_state_.top ()++;
+
+ if (token_ == rbrace_)
+ do_while_state_.top ()--;
+ }
+
+ // Suppress double newline in the "}else", etc., cases.
+ //
+ if (old == rbrace_)
+ {
+ Boolean dw (!do_while_state_.empty () &&
+ do_while_state_.top () == 0);
+
+ if (follow_blocks_.find (token_) != follow_blocks_.end () || dw)
+ {
+ if (dw)
+ do_while_state_.pop ();
+
+ // Reduce double newline after "}" into a single one.
+ //
+ typename Hold::Iterator i (hold_.end ()), b (hold_.begin ());
+
+ for (--i; i != b; --i)
+ {
+ // See if this is the end of the "}\n\n" sequence.
+ //
+ if (*i == '\n')
+ {
+ --i;
+ if (i != b && *i == '\n')
+ {
+ --i;
+ if (*i == '}')
+ {
+ ++i;
+ hold_.erase (i);
+ break;
+ }
+ }
+ }
+ }
+ }
+ else if (token_ != rbrace_)
+ {
+ buffering_ = false;
+ }
+ }
+ }
+
+ public:
+ virtual Void
+ unbuffer ()
+ {
+ AsInt result;
+
+ while (!hold_.empty ())
+ {
+ result = out_.put (hold_.front ());
+
+ //@@ failed
+ if (result == Traits::eof ())
+ throw Write ();
+
+ hold_.pop_front ();
+ }
+ }
+
+ private:
+ Void
+ ensure_new_line ()
+ {
+ if (hold_.empty () || hold_.back () != '\n')
+ {
+ hold_.push_back ('\n');
+ position_ = 0; // Starting a new line.
+ }
+ }
+
+
+ Void
+ output_indentation ()
+ {
+ if (!hold_.empty () && hold_.back () == '\n')
+ {
+ for (UnsignedLong i (0); i < indentation_.top (); ++i)
+ write (' ');
+
+ position_ += indentation_.top ();
+ }
+ }
+
+ AsInt
+ write (AsChar c)
+ {
+ hold_.push_back (c);
+
+ if (!buffering_)
+ {
+ AsInt result (Traits::eof ());
+
+ while (!hold_.empty ())
+ {
+ result = out_.put (hold_.front ());
+
+ if (result == Traits::eof ())
+ throw Write ();
+
+ hold_.pop_front ();
+ }
+
+ return result;
+ }
+ else
+ return c;
+ }
+
+ private:
+ struct Construct
+ {
+ enum Value
+ {
+ other,
+ pp_directive,
+ c_comment,
+ cxx_comment,
+ string_literal,
+ char_literal
+ };
+ };
+
+ Void
+ tokenize (AsChar c, typename Construct::Value old)
+ {
+ //
+ //
+ switch (construct_)
+ {
+ case Construct::pp_directive:
+ {
+ if (old == Construct::other) // Start PP directive
+ retire (c);
+
+ return;
+ }
+ case Construct::c_comment:
+ {
+ if (old == Construct::other) // Start C comment.
+ lexeme_.clear ();
+
+ return;
+ }
+ case Construct::cxx_comment:
+ {
+ if (old == Construct::other) // Start C++ comment.
+ lexeme_.clear ();
+
+ return;
+ }
+ case Construct::string_literal:
+ {
+ if (old == Construct::other) // Start string literal
+ retire (c);
+
+ lexeme_ += c;
+ return;
+ }
+ case Construct::char_literal:
+ {
+ if (old == Construct::other) // Start char literal
+ retire (c);
+
+ lexeme_ += c;
+ return;
+ }
+ default:
+ break;
+ }
+
+ // construct_ == other
+ //
+ switch (old)
+ {
+ case Construct::pp_directive:
+ {
+ // End PP directive (newline).
+ //
+ return;
+ }
+ case Construct::c_comment:
+ {
+ // End C comment.
+ //
+ return;
+ }
+ case Construct::cxx_comment:
+ {
+ // End C++ comment (newline).
+ //
+ return;
+ }
+ case Construct::string_literal:
+ {
+ // End string literal (").
+ //
+ lexeme_ += c;
+ return;
+ }
+ case Construct::char_literal:
+ {
+ // End char literal (').
+ //
+ lexeme_ += c;
+ return;
+ }
+ default:
+ break;
+ }
+
+
+ // construct_ == old == other
+ //
+
+ /*
+
+ The code below is equivalent to this (simpler) code which is
+ unfortunately not fast enough.
+
+ using std::isalpha;
+ using std::isalnum;
+ using std::isdigit;
+ using std::isspace;
+
+ if (c == '_' || isalpha (c, locale_))
+ {
+ if (lexeme_.empty () ||
+ lexeme_[0] == '_' || isalpha (lexeme_[0], locale_))
+ lexeme_ += c;
+ else
+ {
+ retire (c);
+ lexeme_ += c;
+ }
+ }
+ else if (isdigit (c, locale_))
+ {
+ if (lexeme_.empty () ||
+ lexeme_[0] == '_' || isalnum (lexeme_[0], locale_))
+ lexeme_ += c;
+ else
+ {
+ retire (c);
+ lexeme_ += c;
+ }
+ }
+ else // Delimiters
+ {
+ retire (c);
+
+ if (!isspace (c, locale_))
+ lexeme_ += c;
+ }
+ */
+
+ switch (char_class (c))
+ {
+ case CharClass::alpha:
+ {
+ if (lexeme_.empty () ||
+ char_class (lexeme_[0]) == CharClass::alpha)
+ lexeme_ += c;
+ else
+ {
+ retire (c);
+ lexeme_ += c;
+ }
+ break;
+ }
+ case CharClass::digit:
+ {
+ if (lexeme_.empty ())
+ lexeme_ += c;
+ else
+ {
+ typename CharClass::Value cc (char_class (lexeme_[0]));
+
+ if (cc == CharClass::alpha || cc == CharClass::digit)
+ lexeme_ += c;
+ else
+ {
+ retire (c);
+ lexeme_ += c;
+ }
+ }
+ break;
+ }
+ case CharClass::op_punc:
+ {
+ retire (c);
+ lexeme_ += c;
+ break;
+ }
+ case CharClass::space:
+ {
+ retire (c);
+ break;
+ }
+ }
+ }
+
+ struct CharClass
+ {
+ enum Value
+ {
+ alpha, // Alpha + '_'.
+ digit,
+ op_punc, // Operator or punctuation.
+ space
+ };
+
+ };
+
+ typename CharClass::Value
+ char_class (C c)
+ {
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ return CharClass::digit;
+
+ case '!':
+ case '%':
+ case '^':
+ case '&':
+ case '*':
+ case '(':
+ case ')':
+ case '-':
+ case '+':
+ case '=':
+ case '{':
+ case '}':
+ case '|':
+ case '~':
+ case '[':
+ case ']':
+ case '\\':
+ case ';':
+ case '\'':
+ case ':':
+ case '"':
+ case '<':
+ case '>':
+ case '?':
+ case ',':
+ case '.':
+ case '/':
+ return CharClass::op_punc;
+
+ case ' ':
+ case '\n':
+ case '\t':
+ case '\f':
+ case '\r':
+ case '\v':
+ return CharClass::space;
+
+ default:
+ return CharClass::alpha;
+ }
+ }
+
+
+ Void
+ retire (AsChar c)
+ {
+ if (!lexeme_.empty ())
+ {
+ token_.swap (lexeme_);
+ next_token (lexeme_, c);
+ lexeme_.clear ();
+ }
+ }
+
+ private:
+ Buffer<C>& out_;
+ Boolean buffering_; // True if write() should buffer the char.
+ UnsignedLong position_; // Current position on the line.
+ UnsignedLong paren_balance_; // ( ) balance.
+ Cult::Containers::Stack<UnsignedLong> indentation_;
+ UnsignedLong spaces_;
+
+ Boolean suppress_nl_;
+
+ //@@ gcc bug# 18304
+ //
+ typename Construct::Value construct_;
+
+ // Special state stach for the do-while construct. The presence
+ // of an element in the stack indicates that we are in a braced
+ // do-while construct. The value of the element is the brace
+ // balance.
+ Cult::Containers::Stack<UnsignedLong> do_while_state_;
+
+ typedef
+ Cult::Containers::Deque<AsInt>
+ Hold;
+
+ Hold hold_;
+
+ private:
+ String token_; // previously fully recognized token
+ String lexeme_; // current lexeme (accumulator)
+
+ // std::locale locale_;
+
+ // Keywords that may be folowed by a single-line block, e.g., if,
+ // else, etc.
+ //
+ Cult::Containers::Set<String> single_line_blocks_;
+
+ // Keywords that may follow (and be related) to a previous block,
+ // e.g., else, case, catch.
+ //
+ Cult::Containers::Set<String> follow_blocks_;
+
+ String lbrace_;
+ String rbrace_;
+
+ private:
+ // Single-line indented blocks such as if, else, while, etc. The
+ // newline flag indicates whether a new line has been seen after
+ // the keyword. This is needed to properly distinguish cases such
+ // as:
+ //
+ // else if (...)
+ // foo ();
+ //
+ // else
+ // if (...)
+ // foo ();
+ //
+ struct IndentBlockInfo
+ {
+ IndentBlockInfo (Boolean newline, Boolean indented)
+ : newline_ (newline), indented_ (indented)
+ {
+ }
+
+ Boolean newline_;
+ Boolean indented_;
+ };
+
+ Cult::Containers::Stack<IndentBlockInfo> indent_block_;
+ };
+ }
+}
+
+#include <backend-elements/indentation/cxx.txx>
+
+#endif // BACKEND_ELEMENTS_INDENTATION_CXX_HXX
diff --git a/libbackend-elements/backend-elements/indentation/cxx.txx b/libbackend-elements/backend-elements/indentation/cxx.txx
new file mode 100644
index 0000000..9acff37
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/cxx.txx
@@ -0,0 +1,12 @@
+// file : backend-elements/indentation/cxx.txx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ }
+}
+
diff --git a/libbackend-elements/backend-elements/indentation/idl.hxx b/libbackend-elements/backend-elements/indentation/idl.hxx
new file mode 100644
index 0000000..e5a234f
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/idl.hxx
@@ -0,0 +1,290 @@
+// file : backend-elements/indentation/idl.hxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BACKEND_ELEMENTS_INDENTATION_IDL_HXX
+#define BACKEND_ELEMENTS_INDENTATION_IDL_HXX
+
+#include <backend-elements/types.hxx>
+#include <backend-elements/indentation/buffer.hxx>
+
+#include <cult/containers/deque.hxx>
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ template <typename C>
+ class IDL: public Buffer<C>, public NonCopyable
+ {
+ public:
+ typedef
+ typename Buffer<C>::Traits
+ Traits;
+
+ typedef
+ typename Buffer<C>::AsChar
+ AsChar;
+
+ typedef
+ typename Buffer<C>::AsInt
+ AsInt;
+
+ typedef
+ typename Buffer<C>::Write
+ Write;
+
+ public:
+ IDL (Buffer<C>& out)
+ : out_ (out),
+ indentation_ (0),
+ spaces_ (2),
+ construct_ (Construct::other)
+ {
+ }
+
+ public:
+ virtual AsInt
+ put (AsChar c)
+ {
+ AsInt result (Traits::to_int_type (c));
+
+ try
+ {
+ Boolean defaulting (false);
+
+ switch (c)
+ {
+ case '\n':
+ {
+ hold_.push_back (c);
+ break;
+ }
+ case '{':
+ {
+ ensure_new_line ();
+ output_indentation ();
+ result = write (c);
+ ensure_new_line ();
+ indentation_++;
+ break;
+ }
+ case '}':
+ {
+ if (indentation_ > 0) indentation_--;
+
+ // Reduce multiple newlines to one.
+ //
+ while (hold_.size () > 1)
+ {
+ typename Hold::ReverseIterator i (hold_.rbegin ());
+
+ if (*i == '\n' && *(i + 1) == '\n')
+ hold_.pop_back ();
+ else
+ break;
+ }
+
+ ensure_new_line ();
+ output_indentation ();
+
+ hold_.push_back (c);
+
+ // Add double newline after '}'.
+ //
+ hold_.push_back ('\n');
+ hold_.push_back ('\n');
+
+
+ break;
+ }
+ case ';':
+ {
+ // Handling '};' case.
+ //
+
+ Boolean brace (false);
+
+ if (hold_.size () > 1 && hold_.back () == '\n')
+ {
+ Boolean pop_nl (false);
+
+ for (typename Hold::ReverseIterator
+ i (hold_.rbegin ()), e (hold_.rend ()); i != e; ++i)
+ {
+ if (*i != '\n')
+ {
+ if (*i == '}')
+ brace = pop_nl = true;
+
+ break;
+ }
+ }
+
+ if (pop_nl)
+ while (hold_.back () == '\n')
+ hold_.pop_back ();
+ }
+
+ output_indentation ();
+ result = write (c);
+
+ if (brace)
+ {
+ hold_.push_back ('\n');
+ hold_.push_back ('\n');
+ }
+
+ if (construct_ != Construct::string_literal &&
+ construct_ != Construct::char_literal)
+ {
+ ensure_new_line ();
+ }
+ break;
+ }
+ case '\\':
+ {
+ hold_.push_back (c);
+ break;
+ }
+ case '\"':
+ {
+ if (hold_.empty () || hold_.back () != '\\')
+ {
+ // not escape sequence
+ if (construct_ == Construct::string_literal)
+ {
+ construct_ = Construct::other;
+ }
+ else construct_ = Construct::string_literal;
+ }
+
+ defaulting = true;
+ break;
+ }
+ case '\'':
+ {
+ if (hold_.empty () || hold_.back () != '\\')
+ {
+ // not escape sequence
+ if (construct_ == Construct::char_literal)
+ {
+ construct_ = Construct::other;
+ }
+ else construct_ = Construct::char_literal;
+ }
+
+ defaulting = true;
+ break;
+ }
+ default:
+ {
+ defaulting = true;
+ break;
+ }
+ }
+
+ if (defaulting)
+ {
+ output_indentation ();
+ result = write (c);
+ }
+ }
+ catch (Write const&)
+ {
+ result = Traits::eof ();
+ }
+
+ return result;
+ }
+
+ virtual Void
+ unbuffer ()
+ {
+ AsInt result;
+
+ while (!hold_.empty ())
+ {
+ result = out_.put (hold_.front ());
+
+ //@@ failed
+ if (result == Traits::eof ())
+ throw Write ();
+
+ hold_.pop_front ();
+ }
+ }
+
+ private:
+ Void
+ ensure_new_line ()
+ {
+ if (hold_.empty () || hold_.back () != '\n')
+ hold_.push_back ('\n');
+ }
+
+
+ Void
+ output_indentation ()
+ {
+ if (!hold_.empty () && hold_.back () == '\n')
+ for (UnsignedLong i (0); i < indentation_ * spaces_; ++i)
+ write (' ');
+ }
+
+ AsInt
+ write (AsChar c)
+ {
+ hold_.push_back (c);
+
+ AsInt result (Traits::eof ());
+
+ while (!hold_.empty ())
+ {
+ result = out_.put (hold_.front ());
+
+ if (result == Traits::eof ())
+ throw Write ();
+
+ hold_.pop_front ();
+ }
+
+ return result;
+ }
+
+
+ private:
+
+ Buffer<C>& out_;
+ UnsignedLong indentation_;
+ UnsignedLong spaces_;
+
+ Boolean suppress_nl_;
+
+ struct Construct
+ {
+ enum Value
+ {
+ other,
+ string_literal,
+ char_literal
+ };
+ };
+
+ //@@ gcc bug# 18304
+ //
+ typename Construct::Value construct_;
+
+ typedef
+ Cult::Containers::Deque<AsInt>
+ Hold;
+
+ Hold hold_;
+ };
+ }
+}
+
+#include <backend-elements/indentation/idl.txx>
+
+#endif // BACKEND_ELEMENTS_INDENTATION_IDL_HXX
diff --git a/libbackend-elements/backend-elements/indentation/idl.txx b/libbackend-elements/backend-elements/indentation/idl.txx
new file mode 100644
index 0000000..6ddc63e
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/idl.txx
@@ -0,0 +1,11 @@
+// file : backend-elements/indentation/idl.txx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ }
+}
diff --git a/libbackend-elements/backend-elements/indentation/sloc.hxx b/libbackend-elements/backend-elements/indentation/sloc.hxx
new file mode 100644
index 0000000..57e6989
--- /dev/null
+++ b/libbackend-elements/backend-elements/indentation/sloc.hxx
@@ -0,0 +1,277 @@
+// file : backend-elements/indentation/sloc.hxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BACKEND_ELEMENTS_INDENTATION_SLOC_HXX
+#define BACKEND_ELEMENTS_INDENTATION_SLOC_HXX
+
+#include <backend-elements/types.hxx>
+#include <backend-elements/indentation/buffer.hxx>
+
+#include <cctype>
+#include <iostream> //@@ tmp
+
+namespace BackendElements
+{
+ namespace Indentation
+ {
+ template <typename C>
+ class SLOC: public Buffer<C>/*, public NonCopyable*/
+ {
+ public:
+ typedef
+ typename Buffer<C>::Traits
+ Traits;
+
+ typedef
+ typename Buffer<C>::AsChar
+ AsChar;
+
+ typedef
+ typename Buffer<C>::AsInt
+ AsInt;
+
+ typedef
+ typename Buffer<C>::Write
+ Write;
+
+ public:
+ SLOC (Buffer<C>& out)
+ : out_ (out),
+ count_ (0),
+ prev_ ('\0'),
+ code_counted_ (false),
+ construct_ (Construct::code)
+ {
+ }
+
+ UnsignedLong
+ count () const
+ {
+ return count_;
+ }
+
+ public:
+ virtual AsInt
+ put (AsChar c)
+ {
+ typename Construct::Value old (construct_);
+
+ switch (construct_)
+ {
+ case Construct::code:
+ {
+ code (c);
+ break;
+ }
+ case Construct::c_comment:
+ {
+ c_comment (c);
+ break;
+ }
+ case Construct::cxx_comment:
+ {
+ cxx_comment (c);
+ break;
+ }
+ case Construct::char_literal:
+ {
+ char_literal (c);
+ break;
+ }
+ case Construct::string_literal:
+ {
+ string_literal (c);
+ break;
+ }
+ }
+
+ // There are cases when a previous character has been already
+ // 'used' and therefore can not be used again. Good example
+ // would be '/* *//'. Here, the second slash doesn't start
+ // C++ comment since it was already used by C comment.
+ //
+ // To account for this we are going to set prev_ to '\0' when
+ // the mode changes.
+ //
+
+ prev_ = (old == construct_) ? c : '\0';
+
+ return out_.put (c);
+ }
+
+ virtual Void
+ unbuffer ()
+ {
+ }
+
+ private:
+ Void
+ code (AsChar c)
+ {
+ bool count (true);
+
+ switch (c)
+ {
+ case '/':
+ {
+ if (prev_ == '/')
+ {
+ construct_ = Construct::cxx_comment;
+ count = false;
+ }
+ else
+ {
+ // This slash can be a beginning of a comment but we
+ // yet have no way to know. Will have to examine it later
+ // (see below).
+ //
+ count = false;
+ }
+
+ break;
+ }
+ case '*':
+ {
+ if (prev_ == '/')
+ {
+ construct_ = Construct::c_comment;
+ count = false;
+ }
+ break;
+ }
+ case '\'':
+ {
+ construct_ = Construct::char_literal;
+ break;
+ }
+ case '"':
+ {
+ construct_ = Construct::string_literal;
+ break;
+ }
+ case '\n':
+ {
+ code_counted_ = false; // reset for a new line
+ count = false;
+ break;
+ }
+ default:
+ {
+ if (std::isspace (c))
+ count = false;
+ break;
+ }
+ }
+
+ // The second condition here accounts for the fact that we cannot
+ // count '/' right away since it can be a beginning of a comment.
+ //
+ if (!code_counted_ &&
+ (count || (prev_ == '/' && construct_ == Construct::code)))
+ {
+ //std::wcerr << "detected code @ " << c << std::endl;
+ count_++;
+ code_counted_ = true;
+ }
+ }
+
+ Void
+ c_comment (AsChar c)
+ {
+ switch (c)
+ {
+ case '/':
+ {
+ if (prev_ == '*')
+ construct_ = Construct::code;
+ break;
+ }
+ case '\n':
+ {
+ code_counted_ = false; // reset for a new line
+ break;
+ }
+ }
+ }
+
+ Void
+ cxx_comment (AsChar c)
+ {
+ switch (c)
+ {
+ case '\n':
+ {
+ construct_ = Construct::code;
+ code_counted_ = false; // reset for a new line
+ break;
+ }
+ }
+ }
+
+ Void
+ char_literal (AsChar c)
+ {
+ switch (c)
+ {
+ case '\'':
+ {
+ if (prev_ != '\\')
+ construct_ = Construct::code;
+ break;
+ }
+ }
+ }
+
+ Void
+ string_literal (AsChar c)
+ {
+ switch (c)
+ {
+ case '"':
+ {
+ if (prev_ != '\\')
+ construct_ = Construct::code;
+ break;
+ }
+ case '\n':
+ {
+ /*@@ Should I count multi-line string literal as multiple SLOC? */
+ break;
+ }
+ }
+ }
+
+ private:
+ Buffer<C>& out_;
+ UnsignedLong count_;
+
+ AsChar prev_; // previous character or '\0'
+
+ struct Construct
+ {
+ enum Value
+ {
+ code,
+ c_comment,
+ cxx_comment,
+ char_literal,
+ string_literal
+ };
+ };
+
+ // code
+ //
+ bool code_counted_;
+
+ //@@ gcc bug# 18304
+ //
+ typename Construct::Value construct_;
+ };
+ }
+}
+
+//#include <backend-elements/indentation/sloc.txx>
+
+#endif // BACKEND_ELEMENTS_INDENTATION_SLOC_HXX
diff --git a/libbackend-elements/backend-elements/makefile b/libbackend-elements/backend-elements/makefile
new file mode 100644
index 0000000..70a3e4a
--- /dev/null
+++ b/libbackend-elements/backend-elements/makefile
@@ -0,0 +1,63 @@
+# file : backend-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 :=
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+backend_elements.l := #$(out_base)/backend-elements.l
+backend_elements.l.cpp-options := $(out_base)/backend-elements.l.cpp-options
+
+clean := $(out_base)/.clean
+
+
+# Secure default target.
+#
+$(backend_elements.l.cpp-options):
+#$(backend_elements.l):
+
+
+# Imports.
+#
+$(call import,\
+ $(scf_root)/import/libcult/stub.make,\
+ l: cult.l,cpp-options: cult.l.cpp-options)
+
+$(call import,\
+ $(scf_root)/import/libboost/regex/stub.make,\
+ l: re.l,cpp-options: re.l.cpp-options)
+
+
+# Build.
+#
+#$(backend_elements.l): $(cxx_obj) $(cult.l)
+
+#$(cxx_obj): $(backend_elements.l.cpp-options)
+
+$(backend_elements.l.cpp-options): value := -I$(src_root)
+$(backend_elements.l.cpp-options): $(re.l.cpp-options) $(cult.l.cpp-options)
+
+#$(call include-dep,$(cxx_od))
+
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(backend_elements.l.cpp-options)
+
+
+# Clean.
+#
+#$(BackendElements.l).clean \
+
+$(clean): $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(backend_elements.l.cpp-options).clean
+
+
+# How to.
+#
+$(call include,$(bld_root)/cxx/o-l.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
diff --git a/libbackend-elements/backend-elements/regex.hxx b/libbackend-elements/backend-elements/regex.hxx
new file mode 100644
index 0000000..9dc6024
--- /dev/null
+++ b/libbackend-elements/backend-elements/regex.hxx
@@ -0,0 +1,208 @@
+// file : backend-elements/regex.hxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#ifndef BACKEND_ELEMENTS_REGEX_HXX
+#define BACKEND_ELEMENTS_REGEX_HXX
+
+#include <ostream>
+
+#include <boost/regex.hpp>
+
+#include <backend-elements/types.hxx>
+
+namespace BackendElements
+{
+ namespace Regex
+ {
+ template <typename C>
+ struct Format
+ {
+ Format (StringTemplate<C> const& expression,
+ StringTemplate<C> const& description)
+ : expression_ (expression), description_ (description)
+ {
+ }
+
+ StringTemplate<C> const&
+ expression () const
+ {
+ return expression_;
+ }
+
+ StringTemplate<C> const&
+ description () const
+ {
+ return description_;
+ }
+
+ private:
+ StringTemplate<C> expression_;
+ StringTemplate<C> description_;
+ };
+
+ // Regex pattern.
+ //
+ template <typename C>
+ struct Pattern
+ {
+ Pattern ()
+ {
+ }
+
+ Pattern (Char const* p)
+ {
+ init (StringTemplate<C> (p));
+ }
+
+ Pattern (StringTemplate<C> const& p)
+ {
+ init (p);
+ }
+
+ Pattern&
+ operator= (Char const* p)
+ {
+ init (StringTemplate<C> (p));
+ return *this;
+ }
+
+ Pattern&
+ operator= (StringTemplate<C> const& p)
+ {
+ init (p);
+ return *this;
+ }
+
+ public:
+ Boolean
+ match (StringTemplate<C> const& s) const
+ {
+ return regex_match (s, pat_, boost::format_all);
+ }
+
+ StringTemplate<C>
+ merge (StringTemplate<C> const& sub,
+ StringTemplate<C> const& s,
+ Boolean first_only = false) const
+ {
+ if (first_only)
+ return regex_merge (
+ s, pat_, sub, boost::format_all | boost::format_first_only);
+ else
+ return regex_merge ( s, pat_, sub, boost::format_all);
+ }
+
+ public:
+ Boolean
+ empty () const
+ {
+ return pat_.empty ();
+ }
+
+ public:
+ boost::basic_regex<C> const&
+ impl_pattern () const
+ {
+ return pat_;
+ }
+
+ private:
+ Void
+ init (StringTemplate<C> const& r);
+
+ private:
+ boost::basic_regex<C> pat_;
+ };
+
+ template <typename C1, typename C2>
+ inline std::basic_ostream<C1>&
+ operator<< (std::basic_ostream<C1>& os, Pattern<C2> const& p)
+ {
+ return os << p.impl_pattern ().str ().c_str ();
+ }
+
+ // Regex expression: '/pattern/substitution/'.
+ //
+ template <typename C>
+ struct Expression
+ {
+ Expression ()
+ {
+ }
+
+ // Expression is of the form /regex/format/ where '/' can be
+ // replaced with any delimiter.
+ //
+ Expression (Char const* e)
+ {
+ init (StringTemplate<C> (e));
+ }
+
+ Expression (StringTemplate<C> const& e)
+ {
+ init (e);
+ }
+
+ Expression&
+ operator= (Char const* e)
+ {
+ init (StringTemplate<C> (e));
+ return *this;
+ }
+
+ Expression&
+ operator= (StringTemplate<C> const& e)
+ {
+ init (e);
+ return *this;
+ }
+
+ public:
+ Boolean
+ match (StringTemplate<C> const& s) const
+ {
+ return pat_.match (s);
+ }
+
+ StringTemplate<C>
+ merge (StringTemplate<C> const& s, Boolean first_only = false) const
+ {
+ return pat_.merge (sub_, s, first_only);
+ }
+
+ public:
+ const Pattern<C>&
+ pattern () const
+ {
+ return pat_;
+ }
+
+ const StringTemplate<C>&
+ substitution () const
+ {
+ return sub_;
+ }
+
+ public:
+ Boolean
+ empty () const
+ {
+ return pat_.empty () && sub_.empty ();
+ }
+
+ private:
+ Void
+ init (StringTemplate<C> const& r);
+
+ private:
+ Pattern<C> pat_;
+ StringTemplate<C> sub_;
+ };
+ }
+}
+
+#include <backend-elements/regex.txx>
+
+#endif // BACKEND_ELEMENTS_REGEX_HXX
diff --git a/libbackend-elements/backend-elements/regex.txx b/libbackend-elements/backend-elements/regex.txx
new file mode 100644
index 0000000..897e0e8
--- /dev/null
+++ b/libbackend-elements/backend-elements/regex.txx
@@ -0,0 +1,52 @@
+// file : backend-elements/regex.txx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2005-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+namespace BackendElements
+{
+ namespace Regex
+ {
+ template <typename C>
+ Void Pattern<C>::
+ init (StringTemplate<C> const& r)
+ {
+ try
+ {
+ pat_ = r;
+ }
+ catch (boost::regex_error const& e)
+ {
+ throw Format<C> (r, e.what ());
+ }
+ }
+
+ //
+ //
+ template <typename C>
+ Void Expression<C>::
+ init (StringTemplate<C> const& r)
+ {
+ typedef StringTemplate<C> String;
+
+ if (r.empty ())
+ throw Format<C> (r, "empty expression");
+
+ C d (r[0]);
+
+ Size first (0);
+ Size middle (r.find (d, first + 1));
+
+ if (middle == String::npos)
+ throw Format<C> (r, "missing second pattern-substitution separator");
+
+ Size last (r.find (d, middle + 1));
+
+ if (last == String::npos)
+ throw Format<C> (r, "missing third pattern-substitution separator");
+
+ pat_ = String (r, first + 1, middle - first - 1);
+ sub_.assign (r, middle + 1, last - middle - 1);
+ }
+ }
+}
diff --git a/libbackend-elements/backend-elements/types.hxx b/libbackend-elements/backend-elements/types.hxx
new file mode 100644
index 0000000..f309f5d
--- /dev/null
+++ b/libbackend-elements/backend-elements/types.hxx
@@ -0,0 +1,16 @@
+// file : backend-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 BACKEND_ELEMENTS_TYPES_HXX
+#define BACKEND_ELEMENTS_TYPES_HXX
+
+#include <cult/types.hxx>
+
+namespace BackendElements
+{
+ using namespace Cult::Types;
+}
+
+#endif // BACKEND_ELEMENTS_TYPES_HXX
diff --git a/libbackend-elements/build/bootstrap.make b/libbackend-elements/build/bootstrap.make
new file mode 100644
index 0000000..17981a7
--- /dev/null
+++ b/libbackend-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 := libbackend-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/libbackend-elements/build/cxx/configuration-dynamic.make b/libbackend-elements/build/cxx/configuration-dynamic.make
new file mode 100644
index 0000000..568ab40
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/cxx/gnu/configuration-dynamic.make b/libbackend-elements/build/cxx/gnu/configuration-dynamic.make
new file mode 100644
index 0000000..f3fe64d
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/export/libbackend-elements/stub.make b/libbackend-elements/build/export/libbackend-elements/stub.make
new file mode 100644
index 0000000..10b4ecb
--- /dev/null
+++ b/libbackend-elements/build/export/libbackend-elements/stub.make
@@ -0,0 +1,13 @@
+# file : build/import/libbackend-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)/backend-elements/makefile,$(out_root))
+
+#$(out_root)/backend-elements/backend-elements.l
+
+$(call export,\
+ l: ,\
+ cpp-options: $(out_root)/backend-elements/backend-elements.l.cpp-options)
+
diff --git a/libbackend-elements/build/import/libbackend-elements/LICENSE b/libbackend-elements/build/import/libbackend-elements/LICENSE
new file mode 120000
index 0000000..5853aae
--- /dev/null
+++ b/libbackend-elements/build/import/libbackend-elements/LICENSE
@@ -0,0 +1 @@
+../../../LICENSE \ No newline at end of file
diff --git a/libbackend-elements/build/import/libbackend-elements/configuration-rules.make b/libbackend-elements/build/import/libbackend-elements/configuration-rules.make
new file mode 100644
index 0000000..4c65d9e
--- /dev/null
+++ b/libbackend-elements/build/import/libbackend-elements/configuration-rules.make
@@ -0,0 +1,15 @@
+# file : build/import/libbackend-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/libbackend-elements/configuration-dynamic.make: | $(dcf_root)/import/libbackend-elements/.
+ $(call message,,$(scf_root)/import/libbackend-elements/configure $@)
+
+ifndef %foreign%
+
+disfigure::
+ $(call message,rm $(dcf_root)/import/libbackend-elements/configuration-dynamic.make,\
+rm -f $(dcf_root)/import/libbackend-elements/configuration-dynamic.make)
+
+endif
diff --git a/libbackend-elements/build/import/libbackend-elements/configure b/libbackend-elements/build/import/libbackend-elements/configure
new file mode 100755
index 0000000..ab5cd7f
--- /dev/null
+++ b/libbackend-elements/build/import/libbackend-elements/configure
@@ -0,0 +1,55 @@
+#! /usr/bin/env bash
+
+# file : build/import/libbackend-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 'libbackend-elements' for '$project_name'."
+$echo
+
+$echo
+$echo "Would you like to configure dependency on the installed version"
+$echo "of 'libbackend-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 'libbackend-elements'."
+$echo
+
+src_root=`read_path --directory --exist`
+
+$echo
+$echo "Please enter the out_root for 'libbackend-elements'."
+$echo
+
+out_root=`read_path --directory $src_root`
+
+fi
+
+echo libbackend_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/libbackend-elements/build/import/libbackend-elements/stub.make b/libbackend-elements/build/import/libbackend-elements/stub.make
new file mode 100644
index 0000000..839d388
--- /dev/null
+++ b/libbackend-elements/build/import/libbackend-elements/stub.make
@@ -0,0 +1,32 @@
+# file : build/import/libbackend-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/libbackend-elements/configuration-rules.make,$(dcf_root))
+
+libbackend_elements_installed :=
+
+$(call -include,$(dcf_root)/import/libbackend-elements/configuration-dynamic.make)
+
+ifdef libbackend_elements_installed
+
+ifeq ($(libbackend_elements_installed),y)
+
+#-lbackend-elements
+
+$(call export,l: -lcult -lboost_regex,cpp_options: )
+
+else
+
+# Include export stub.
+#
+$(call include,$(scf_root)/export/libbackend-elements/stub.make)
+
+endif
+
+else
+
+.NOTPARALLEL:
+
+endif
diff --git a/libbackend-elements/build/import/libboost/LICENSE b/libbackend-elements/build/import/libboost/LICENSE
new file mode 100644
index 0000000..3912109
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/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/libbackend-elements/build/import/libboost/configuration-dynamic.make b/libbackend-elements/build/import/libboost/configuration-dynamic.make
new file mode 100644
index 0000000..ab55882
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/configuration-dynamic.make
@@ -0,0 +1,8 @@
+libboost_installed := y
+libboost_suffix := $(BOOST_LIB_SUFFIX)
+
+ifeq ($(BOOST_LINK_SYSTEM),n)
+libboost_system := n
+else
+libboost_system := y
+endif
diff --git a/libbackend-elements/build/import/libboost/configuration-rules.make b/libbackend-elements/build/import/libboost/configuration-rules.make
new file mode 100644
index 0000000..bfe3116
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/configuration-rules.make
@@ -0,0 +1,15 @@
+# file : build/import/libboost/configuration-rules.make
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(dcf_root)/import/libboost/configuration-dynamic.make: | $(dcf_root)/import/libboost/.
+ $(call message,,$(scf_root)/import/libboost/configure $@)
+
+ifndef %foreign%
+
+disfigure::
+ $(call message,rm $(dcf_root)/import/libboost/configuration-dynamic.make,\
+rm -f $(dcf_root)/import/libboost/configuration-dynamic.make)
+
+endif
diff --git a/libbackend-elements/build/import/libboost/configure b/libbackend-elements/build/import/libboost/configure
new file mode 100755
index 0000000..2c62d45
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/configure
@@ -0,0 +1,65 @@
+#! /usr/bin/env bash
+
+# file : build/import/libboost/configure
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+
+# $1 - out config file
+#
+# bld_root - build root
+# project_name - project name
+#
+
+source $bld_root/dialog.bash
+
+
+$echo
+$echo "Configuring external dependency on 'boost libraries' for '$project_name'."
+$echo
+
+$echo
+$echo "Would you like to configure dependency on the installed version"
+$echo "of 'boost libraries' as opposed to the development build?"
+$echo
+
+installed=`read_y_n y`
+
+if [ "$installed" = "n" ]; then
+
+ $echo
+ $echo "Please enter the 'boost' root directory."
+ $echo
+
+ root=`read_path --directory --exist`
+
+ $echo
+ $echo "Please select the library type you would like to use:"
+ $echo
+ $echo "(1) archive"
+ $echo "(2) shared object"
+ $echo
+
+ type=`read_option "archive shared" "shared"`
+fi
+
+$echo
+$echo "Please enter optional suffix that may be embedded into the"
+$echo "boost library names. For example, if your library names are in"
+$echo "the libboost_regex-gcc41-mt-d.so form, then enter -gcc41-mt-d"
+$echo "Otherwise leave this field blank."
+$echo
+
+suffix=
+read -e -p "[]: " suffix
+
+echo libboost_installed := $installed >$1
+echo libboost_suffix := $suffix >>$1
+
+if [ "$installed" = "n" ]; then
+
+ echo libboost_root := $root >>$1
+ echo libboost_type := $type >>$1
+
+fi
diff --git a/libbackend-elements/build/import/libboost/regex/rules.make b/libbackend-elements/build/import/libboost/regex/rules.make
new file mode 100644
index 0000000..3b5a0f8
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/regex/rules.make
@@ -0,0 +1,38 @@
+# file : build/import/libboost/regex/rules.make
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(dcf_root)/import/libboost/%: root := $(libboost_root)
+
+$(dcf_root)/import/libboost/regex/regex.l: \
+ | $(dcf_root)/import/libboost/regex/.
+
+ifeq ($(libboost_type),archive)
+
+$(dcf_root)/import/libboost/regex/regex.l: \
+ $(libboost_root)/stage/lib/libboost_regex$(libboost_suffix).a
+ @echo $< >$@
+
+else
+
+$(dcf_root)/import/libboost/regex/regex.l: \
+ $(libboost_root)/stage/lib/libboost_regex$(libboost_suffix).so
+ @echo $< >$@
+ @echo rpath:$(root)/stage/lib >>$@
+
+endif
+
+
+$(dcf_root)/import/libboost/regex/regex.l.cpp-options: \
+ | $(dcf_root)/import/libboost/regex/.
+ @echo include: -I$(root) >$@
+
+ifndef %foreign%
+
+disfigure::
+ $(call message,rm $(dcf_root)/import/libboost/regex/regex.l,\
+rm -f $(dcf_root)/import/libboost/regex/regex.l)
+ $(call message,,rm -f $(dcf_root)/import/libboost/regex/regex.l.cpp-options)
+
+endif
diff --git a/libbackend-elements/build/import/libboost/regex/stub.make b/libbackend-elements/build/import/libboost/regex/stub.make
new file mode 100644
index 0000000..2095e33
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/regex/stub.make
@@ -0,0 +1,32 @@
+# file : build/import/libboost/regex/stub.make
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2005-2008 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+$(call include-once,$(scf_root)/import/libboost/configuration-rules.make,$(dcf_root))
+
+libboost_installed :=
+
+$(call -include,$(dcf_root)/import/libboost/configuration-dynamic.make)
+
+ifdef libboost_installed
+
+ifeq ($(libboost_installed),y)
+
+$(call export,l: -lboost_regex$(libboost_suffix),cpp_options: )
+
+else
+
+$(call include-once,$(scf_root)/import/libboost/regex/rules.make,$(dcf_root))
+
+$(call export,\
+ l: $(dcf_root)/import/libboost/regex/regex.l,\
+ cpp-options: $(dcf_root)/import/libboost/regex/regex.l.cpp-options)
+
+endif
+
+else
+
+.NOTPARALLEL:
+
+endif
diff --git a/libbackend-elements/build/import/libboost/version b/libbackend-elements/build/import/libboost/version
new file mode 100644
index 0000000..a918a2a
--- /dev/null
+++ b/libbackend-elements/build/import/libboost/version
@@ -0,0 +1 @@
+0.6.0
diff --git a/libbackend-elements/build/import/libcult/LICENSE b/libbackend-elements/build/import/libcult/LICENSE
new file mode 100644
index 0000000..3912109
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/import/libcult/configuration-dynamic.make b/libbackend-elements/build/import/libcult/configuration-dynamic.make
new file mode 100644
index 0000000..73c92bb
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/import/libcult/configuration-rules.make b/libbackend-elements/build/import/libcult/configuration-rules.make
new file mode 100644
index 0000000..dc19df4
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/import/libcult/configure b/libbackend-elements/build/import/libcult/configure
new file mode 100755
index 0000000..afa4c9c
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/import/libcult/stub.make b/libbackend-elements/build/import/libcult/stub.make
new file mode 100644
index 0000000..f5f7691
--- /dev/null
+++ b/libbackend-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/libbackend-elements/build/ld/configuration-lib-dynamic.make b/libbackend-elements/build/ld/configuration-lib-dynamic.make
new file mode 100644
index 0000000..74c8885
--- /dev/null
+++ b/libbackend-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/libbackend-elements/documentation/BUGS b/libbackend-elements/documentation/BUGS
new file mode 100644
index 0000000..102bf7d
--- /dev/null
+++ b/libbackend-elements/documentation/BUGS
@@ -0,0 +1 @@
+@@ Should properly depend on libboost.
diff --git a/libbackend-elements/documentation/TODO b/libbackend-elements/documentation/TODO
new file mode 100644
index 0000000..68f4d71
--- /dev/null
+++ b/libbackend-elements/documentation/TODO
@@ -0,0 +1 @@
+@@ examples
diff --git a/libbackend-elements/documentation/default.css b/libbackend-elements/documentation/default.css
new file mode 100644
index 0000000..7242a94
--- /dev/null
+++ b/libbackend-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/libbackend-elements/documentation/index.xhtml b/libbackend-elements/documentation/index.xhtml
new file mode 100644
index 0000000..028cc40
--- /dev/null
+++ b/libbackend-elements/documentation/index.xhtml
@@ -0,0 +1,56 @@
+<?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>libbackend-elements/documentation</title>
+
+ <meta name="author" content="Boris Kolpackov"/>
+ <meta name="copyright" content="&copy; 2005-2010 Boris Kolpackov"/>
+ <meta name="keywords" content="c++,library,compiler,backend"/>
+ <meta name="description" content="libbackend-elements/documentation"/>
+
+ <link rel="stylesheet" type="text/css" href="default.css"/>
+
+</head>
+
+<body>
+
+<div id="navigation">
+<p>
+<a href=".."><code>libbackend-elements</code></a> <code>/</code>
+<code>documentation</code>
+</p>
+</div>
+
+<div id="content">
+<p><i>libbackend-elements</i> contains a collection of
+indentation buffers for automatic source code indentation. Indentation
+buffers can be attached to any <code>std::ostream</code> instance. C++
+and OMG IDL are supported in this version.</p>
+</div>
+
+<div id="docinfo">
+<p>Copyright &copy; 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/libbackend-elements/makefile b/libbackend-elements/makefile
new file mode 100644
index 0000000..3929387
--- /dev/null
+++ b/libbackend-elements/makefile
@@ -0,0 +1,17 @@
+# 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)/
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+$(default): $(out_base)/backend-elements/ $(out_base)/tests/
+$(test): $(out_base)/tests/.test
+$(clean): $(out_base)/backend-elements/.clean $(out_base)/tests/.clean
+
+$(call import,$(src_base)/backend-elements/makefile)
+$(call import,$(src_base)/tests/makefile)
diff --git a/libbackend-elements/tests/indentation/cxx/driver.cxx b/libbackend-elements/tests/indentation/cxx/driver.cxx
new file mode 100644
index 0000000..adfc2fc
--- /dev/null
+++ b/libbackend-elements/tests/indentation/cxx/driver.cxx
@@ -0,0 +1,105 @@
+// file : tests/indentation/cxx/driver.cxx
+// author : Boris Kolpackov <boris@kolpackov.net>
+// copyright : Copyright (c) 2006-2010 Boris Kolpackov
+// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
+
+#include <iostream>
+
+#include <cult/types.hxx>
+
+#include <backend-elements/indentation/cxx.hxx>
+#include <backend-elements/indentation/clip.hxx>
+
+using namespace Cult::Types;
+using namespace BackendElements::Indentation;
+
+using std::cout;
+using std::endl;
+
+Int
+main ()
+{
+ std::ostream& os (cout);
+ Clip<CXX, Char> clip (os);
+
+ os << "if (true)"
+ << "{"
+ << "// Hello there" << endl
+ << "//" << endl
+ << "a ();"
+ << "}"
+ << "else"
+ << "{"
+ << "b ();"
+ << "}";
+
+ os << "if (false)"
+ << "{"
+ << "if (true)"
+ << "{"
+ << "// test" << endl
+ << "}"
+ << "else"
+ << "{"
+ << "// test" << endl
+ << "b ();"
+ << "}"
+ << "}";
+
+ os << "namespace a"
+ << "{"
+ << "void f ();"
+ << "}"
+ << "#if defined(__HP_aCC) && __HP_aCC <= 39999" << endl
+ << "#include <foo.h>" << endl
+ << "#endif" << endl
+ << endl
+ << "namespace b"
+ << "{"
+ << "void f ();"
+ << "}";
+
+ // Test do-while handling.
+ //
+ os << "do" << endl
+ << "f ();"
+ << "while (false);"
+ << endl;
+
+ os << "do"
+ << "{"
+ << "f ();"
+ << "}"
+ << "while (false);"
+ << endl;
+
+ os << "do"
+ << "{"
+ << "if (f ())"
+ << "{"
+ << "g ();"
+ << "}"
+ << "}"
+ << "while (false);"
+ << endl;
+
+ os << "do"
+ << "{"
+ << "do" << endl
+ << "f ();"
+ << "while (false);"
+ << "}"
+ << "while (false);"
+ << endl;
+
+ os << "do"
+ << "{"
+ << "do"
+ << "{"
+ << "f ();"
+ << "}"
+ << "while (false);"
+ << "}"
+ << "while (false);"
+ << endl;
+}
diff --git a/libbackend-elements/tests/indentation/cxx/makefile b/libbackend-elements/tests/indentation/cxx/makefile
new file mode 100644
index 0000000..ff2e15d
--- /dev/null
+++ b/libbackend-elements/tests/indentation/cxx/makefile
@@ -0,0 +1,57 @@
+# file : tests/indentation/cxx/makefile
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2006-2010 Boris Kolpackov
+# license : GNU GPL v2 + exceptions; 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)
+
+#be.l := $(out_root)/backend-elements/backend-elements.l
+be.l.cpp-options := $(out_root)/backend-elements/backend-elements.l.cpp-options
+
+driver := $(out_base)/driver
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+
+# Build.
+#
+$(driver): $(cxx_obj) #$(be.l)
+
+$(cxx_obj) $(cxx_od): $(be.l.cpp-options)
+
+$(call include-dep,$(cxx_od))
+
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(driver)
+
+
+# Test.
+#
+$(test): driver := $(driver)
+$(test): $(driver) $(src_base)/output.cxx
+ $(driver) | diff -u $(src_base)/output.cxx -
+
+
+# Clean.
+#
+$(clean): $(driver).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)/backend-elements/makefile)
diff --git a/libbackend-elements/tests/indentation/cxx/output.cxx b/libbackend-elements/tests/indentation/cxx/output.cxx
new file mode 100644
index 0000000..1a22bc7
--- /dev/null
+++ b/libbackend-elements/tests/indentation/cxx/output.cxx
@@ -0,0 +1,75 @@
+if (true)
+{
+ // Hello there
+ //
+ a ();
+}
+else
+{
+ b ();
+}
+
+if (false)
+{
+ if (true)
+ {
+ // test
+ }
+ else
+ {
+ // test
+ b ();
+ }
+}
+
+namespace a
+{
+ void f ();
+}
+
+#if defined(__HP_aCC) && __HP_aCC <= 39999
+#include <foo.h>
+#endif
+
+namespace b
+{
+ void f ();
+}
+
+do
+ f ();
+while (false);
+
+do
+{
+ f ();
+}
+while (false);
+
+do
+{
+ if (f ())
+ {
+ g ();
+ }
+}
+while (false);
+
+do
+{
+ do
+ f ();
+ while (false);
+}
+while (false);
+
+do
+{
+ do
+ {
+ f ();
+ }
+ while (false);
+}
+while (false);
+
diff --git a/libbackend-elements/tests/indentation/makefile b/libbackend-elements/tests/indentation/makefile
new file mode 100644
index 0000000..debbeec
--- /dev/null
+++ b/libbackend-elements/tests/indentation/makefile
@@ -0,0 +1,18 @@
+# file : tests/indentation/makefile
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2006-2010 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+tests := cxx
+
+default := $(out_base)/
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/libbackend-elements/tests/makefile b/libbackend-elements/tests/makefile
new file mode 100644
index 0000000..2e14098
--- /dev/null
+++ b/libbackend-elements/tests/makefile
@@ -0,0 +1,18 @@
+# file : tests/makefile
+# author : Boris Kolpackov <boris@kolpackov.net>
+# copyright : Copyright (c) 2006-2010 Boris Kolpackov
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
+
+tests := indentation
+
+default := $(out_base)/
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/libbackend-elements/version b/libbackend-elements/version
new file mode 100644
index 0000000..f8a696c
--- /dev/null
+++ b/libbackend-elements/version
@@ -0,0 +1 @@
+1.7.2