]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.yy
refactor gcd() a little bit (no functional changes).
[ginac.git] / ginsh / ginsh_parser.yy
index 9682b936aa2845bc1de00236c245584e7c6a41c1..b8c6875a2f96da32fb99817c3e82c5c5334222b7 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with yacc/bison. */
 
 /*
- *  GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2008 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
@@ -45,6 +45,7 @@
 
 #define YYERROR_VERBOSE 1
 
+#ifdef REALLY_HAVE_LIBREADLINE
 // Original readline settings
 static int orig_completion_append_character;
 #if (GINAC_RL_VERSION_MAJOR < 4) || (GINAC_RL_VERSION_MAJOR == 4 && GINAC_RL_VERSION_MINOR < 2)
@@ -58,6 +59,7 @@ static const char *orig_basic_word_break_characters;
 #else
 #define GINAC_RL_COMPLETER_CAST(a) (a)
 #endif
+#endif // REALLY_HAVE_LIBREADLINE
 
 // Expression stack for %, %% and %%%
 static void push(const ex &e);
@@ -328,6 +330,7 @@ static ex f_evalf1(const exprseq &e) {return e[0].evalf();}
 static ex f_evalm(const exprseq &e) {return e[0].evalm();}
 static ex f_eval_integ(const exprseq &e) {return e[0].eval_integ();}
 static ex f_expand(const exprseq &e) {return e[0].expand();}
+static ex f_factor(const exprseq &e) {return factor(e[0]);}
 static ex f_gcd(const exprseq &e) {return gcd(e[0], e[1]);}
 static ex f_has(const exprseq &e) {return e[0].has(e[1]) ? ex(1) : ex(0);}
 static ex f_lcm(const exprseq &e) {return lcm(e[0], e[1]);}
@@ -608,6 +611,7 @@ static const fcn_init builtin_fcns[] = {
        {"evalm", f_evalm, 1},
        {"eval_integ", f_eval_integ, 1},
        {"expand", f_expand, 1},
+       {"factor", f_factor, 1},
        {"find", f_find, 2},
        {"fsolve", f_fsolve, 4},
        {"gcd", f_gcd, 2},
@@ -715,7 +719,8 @@ static ex f_ginac_function(const exprseq &es, int serial)
 }
 
 // All registered GiNaC functions
-void GiNaC::ginsh_get_ginac_functions(void)
+namespace GiNaC {
+void ginsh_get_ginac_functions(void)
 {
        vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
        unsigned serial = 0;
@@ -725,6 +730,7 @@ void GiNaC::ginsh_get_ginac_functions(void)
                serial++;
        }
 }
+}
 
 
 /*
@@ -848,6 +854,7 @@ static char *fcn_generator(const char *text, int state)
        return NULL;
 }
 
+#ifdef REALLY_HAVE_LIBREADLINE
 static char **fcn_completion(const char *text, int start, int end)
 {
        if (rl_line_buffer[0] == '!') {
@@ -872,11 +879,12 @@ static char **fcn_completion(const char *text, int start, int end)
 #endif
        }
 }
+#endif // REALLY_HAVE_LIBREADLINE
 
 void greeting(void)
 {
     cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " V" << VERSION << ")" << endl;
-    cout << "  __,  _______  Copyright (C) 1999-2005 Johannes Gutenberg University Mainz,\n"
+    cout << "  __,  _______  Copyright (C) 1999-2008 Johannes Gutenberg University Mainz,\n"
          << " (__) *       | Germany.  This is free software with ABSOLUTELY NO WARRANTY.\n"
          << "  ._) i N a C | You are welcome to redistribute it under certain conditions.\n"
          << "<-------------' For details type `warranty;'.\n" << endl;
@@ -915,6 +923,7 @@ int main(int argc, char **argv)
        insert_help("print_latex", "print_latex(expression) - prints a LaTeX representation of the given expression");
        insert_help("print_csrc", "print_csrc(expression) - prints a C source code representation of the given expression");
 
+#ifdef REALLY_HAVE_LIBREADLINE
        // Init readline completer
        rl_readline_name = argv[0];
 #if (GINAC_RL_VERSION_MAJOR < 4) || (GINAC_RL_VERSION_MAJOR == 4 && GINAC_RL_VERSION_MINOR < 2)
@@ -924,6 +933,7 @@ int main(int argc, char **argv)
 #endif
        orig_completion_append_character = rl_completion_append_character;
        orig_basic_word_break_characters = rl_basic_word_break_characters;
+#endif
 
        // Init input file list, open first file
        num_files = argc - 1;