]> www.ginac.de Git - ginac.git/commitdiff
Parser: don't bother to generate 3 (C++) functions with autogen.
authorAlexei Sheplyakov <alexei.sheplyakov@gmail.com>
Sun, 22 May 2011 12:15:42 +0000 (15:15 +0300)
committerJens Vollinga <jensv@nikhef.nl>
Sun, 22 May 2011 13:21:49 +0000 (15:21 +0200)
INSTALL
ginac/Makefile.am
ginac/parser/builtin_fcns.def [deleted file]
ginac/parser/default_reader.cpp [moved from ginac/parser/default_reader.tpl with 61% similarity]

diff --git a/INSTALL b/INSTALL
index 3be16c1fe03b0d68341b61cb9cbea84c2e0472cc..3c188b667cd4043f941616c2e16546859b3d9ede 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -30,8 +30,7 @@ Known not to work with:
    is missing there.
 
 If you install from git, you also need GNU autoconf (>=2.59), automake (>=1.8),
-libtool (>= 1.5), bison (>= 2.3), flex (>= 2.5.33), autogen (>= 5.6.0) to be
-installed.
+libtool (>= 1.5), bison (>= 2.3), flex (>= 2.5.33) to be installed.
 
 
 INSTALLATION
index bc2e1b851f607aae3a160258c5b9c81f8a4fc193..dce098d5fb213eec2c1d2aae7d7384be40625926 100644 (file)
@@ -13,7 +13,7 @@ libginac_la_SOURCES = add.cpp archive.cpp basic.cpp clifford.cpp color.cpp \
   parser/parse_binop_rhs.cpp \
   parser/parser.cpp \
   parser/parse_context.cpp \
-  parser/builtin_fcns.cpp \
+  parser/default_reader.cpp \
   parser/lexer.cpp \
   parser/lexer.h \
   parser/parser_compat.cpp \
@@ -67,22 +67,7 @@ ginacinclude_HEADERS = ginac.h add.h archive.h assertion.h basic.h class_info.h
   parser/parser.h \
   parser/parse_context.h
 
-EXTRA_DIST = function.pl version.h.in \
-parser/default_reader.tpl parser/builtin_fcns.def
-
-# Files produced by autogen(1) from templates
-$(srcdir)/parser/builtin_fcns.cpp: $(srcdir)/parser/builtin_fcns.def $(srcdir)/parser/default_reader.tpl
-       set -e; if [ -n "$(AUTOGEN)" ]; then \
-               cd $(srcdir)/parser; \
-               $(AUTOGEN) -T default_reader.tpl builtin_fcns.def; \
-       elif [ -f $@ ]; then \
-               echo "WARNING: AutoGen is not available, the \"$@\" file WON'T be re-generated"; \
-       else \
-               echo "*** ERROR: the \"$@\" file does not exist, and AutoGen is not installed on your system"; \
-               echo "***        Please install AutoGen (http://www.gnu.org/software/autogen)"; \
-               exit 1; \
-       fi
-               
+EXTRA_DIST = function.pl version.h.in
 
 # Files which are generated by perl scripts
 $(srcdir)/function.h $(srcdir)/function.cpp: $(srcdir)/function.pl
diff --git a/ginac/parser/builtin_fcns.def b/ginac/parser/builtin_fcns.def
deleted file mode 100644 (file)
index 96cd0a2..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-Autogen definitions ginacfcns;
-
-/* Thease are not functions, but anyway ... */
-function = { name = "sqrt"; };
-
-function = { 
-       name = "pow";
-       args = 2;
-};
-
-function = {
-       name = "power";
-       args = 2;
-};
similarity index 61%
rename from ginac/parser/default_reader.tpl
rename to ginac/parser/default_reader.cpp
index 006fb908c28402f2d61fa5cacdee904788a091b7..4f8c69c365d19be46be795cd7e003eb4e2a011ad 100644 (file)
@@ -1,20 +1,26 @@
-[+ AutoGen5 template .cpp +][+ 
-COMMENT a part of GiNaC parser -- construct functions from a byte stream.
-+][+
-(use-modules (ice-9 format))
+/** @file default_reader.cpp
+ *
+ *  Implementation of the default and builtin readers (part of GiNaC's parser).
+ **/
 
-(define (sequence start end . step)
-  (let ((step (if (null? step) 1 (car step))))
-    (let loop ((n start))
-      (if (> n end) '() (cons n (loop (+ step n)))))))
-+]/*
-[+ (dne " * " " * " ) +]
+/*
+ *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ *
+ *  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.
  *
- * If you want to change this file, edit either `[+ (def-file) +]' or
- * `[+ (tpl-file) +]' file, and run the following command:
+ *  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.
  *
- * autogen -T [+ (tpl-file) +] [+ (def-file) +]
+ *  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 Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
+
 #include "parse_context.h"
 #include "power.h"
 #include "operators.h"
@@ -29,16 +35,24 @@ COMMENT a part of GiNaC parser -- construct functions from a byte stream.
 
 namespace GiNaC
 {
-[+ FOR function +]
-static ex [+ (get "name") +]_reader(const exvector& ev)
+
+static ex sqrt_reader(const exvector& ev)
+{
+       return GiNaC::sqrt(ev[0]);
+}
+static ex pow_reader(const exvector& ev)
+{
+       return GiNaC::pow(ev[0], ev[1]);
+}
+static ex power_reader(const exvector& ev)
 {
-       return GiNaC::[+ (get "name") +]([+
-               (let ((nargs (if (exist? "args")
-                                (string->number (get "args")) 1)))
-                 (format '#f "~{ev[~a]~^, ~}" (sequence 0 (- nargs 1)))) +]);
-}[+ ENDFOR +]
+       return GiNaC::power(ev[0], ev[1]);
+}
+
 
 // function::registered_functions() is protected, but we need to access it
+// TODO: add a proper const method to the `function' class, so we don't
+// need this silly hack any more.
 class registered_functions_hack : public function
 {
 public:
@@ -69,11 +83,10 @@ const prototype_table& get_default_reader()
        static bool initialized = false;
        static prototype_table reader;
        if (!initialized) {
-               [+ FOR function +]
-               reader[make_pair("[+ (get "name") +]", [+ 
-                       (if (exist? "args") (get "args") "1")
-                       +])] = [+ (get "name") +]_reader;[+
-               ENDFOR +]
+               
+               reader[make_pair("sqrt", 1)] = sqrt_reader;
+               reader[make_pair("pow", 2)] = pow_reader;
+               reader[make_pair("power", 2)] = power_reader;
                std::vector<function_options>::const_iterator it =
                        registered_functions_hack::get_registered_functions().begin();
                std::vector<function_options>::const_iterator end =
@@ -95,11 +108,10 @@ const prototype_table& get_builtin_reader()
        static bool initialized = false;
        static prototype_table reader;
        if (!initialized) {
-               [+ FOR function +]
-               reader[make_pair("[+ (get "name") +]", [+ 
-                       (if (exist? "args") (get "args") "1")
-                       +])] = [+ (get "name") +]_reader;[+
-               ENDFOR +]
+               
+               reader[make_pair("sqrt", 1)] = sqrt_reader;
+               reader[make_pair("pow", 2)] = pow_reader;
+               reader[make_pair("power", 2)] = power_reader;
                enum {
                        log,
                        exp,