]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.ypp
De-document eval() in ginsh help and manpage.
[ginac.git] / ginsh / ginsh_parser.ypp
index c16c35cf42f64a240f32a58213b01f903198fcc0..96a864a82cbc40b8c7fcbcb2fc4970fafb2d17f0 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with yacc/bison. */
 
 /*
- *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2015 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
@@ -218,8 +218,8 @@ line        : ';'
                cout << "FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n";
                cout << "details.\n";
                cout << "You should have received a copy of the GNU General Public License along with\n";
-               cout << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n";
-               cout << "Cambridge, MA 02139, USA.\n";
+               cout << "this program. If not, write to the Free Software Foundation,\n";
+               cout << "51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n";
        }
        | T_XYZZY               {cout << "Nothing happens.\n";}
        | T_INVENTORY           {cout << "You're not carrying anything.\n";}
@@ -242,7 +242,7 @@ exp : T_NUMBER              {$$ = $1;}
                if (i == assigned_symbol_table.end())
                        $$ = $1;
                else
-                       $$ = i->second.eval();
+                       $$ = i->second;
        }
        | '\'' T_SYMBOL '\''    {$$ = $2;}
        | T_LITERAL             {$$ = $1;}
@@ -279,7 +279,7 @@ exp : T_NUMBER              {$$ = $1;}
        | '[' matrix ']'        {$$ = lst_to_matrix(ex_to<lst>($2));}
        ;
 
-exprseq        : exp                   {$$ = exprseq($1);}
+exprseq        : exp                   {$$ = exprseq{$1};}
        | exprseq ',' exp       {exprseq es(ex_to<exprseq>($1)); $$ = es.append($3);}
        ;
 
@@ -287,15 +287,15 @@ list_or_empty: /* empty */        {$$ = *new lst;}
        | list                  {$$ = $1;}
        ;
 
-list   : exp                   {$$ = lst($1);}
+list   : exp                   {$$ = lst{$1};}
        | list ',' exp          {lst l(ex_to<lst>($1)); $$ = l.append($3);}
        ;
 
-matrix : '[' row ']'           {$$ = lst($2);}
+matrix : '[' row ']'           {$$ = lst{$2};}
        | matrix ',' '[' row ']' {lst l(ex_to<lst>($1)); $$ = l.append($4);}
        ;
 
-row    : exp                   {$$ = lst($1);}
+row    : exp                   {$$ = lst{$1};}
        | row ',' exp           {lst l(ex_to<lst>($1)); $$ = l.append($3);}
        ;
 
@@ -331,7 +331,6 @@ static ex f_collect_common_factors(const exprseq &e) {return collect_common_fact
 static ex f_convert_H_to_Li(const exprseq &e) {return convert_H_to_Li(e[0], e[1]);}
 static ex f_degree(const exprseq &e) {return e[0].degree(e[1]);}
 static ex f_denom(const exprseq &e) {return e[0].denom();}
-static ex f_eval1(const exprseq &e) {return e[0].eval();}
 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();}
@@ -414,12 +413,6 @@ static ex f_divide(const exprseq &e)
                return fail();
 }
 
-static ex f_eval2(const exprseq &e)
-{
-       CHECK_ARG(1, numeric, eval);
-       return e[0].eval(ex_to<numeric>(e[1]).to_int());
-}
-
 static ex f_evalf2(const exprseq &e)
 {
        CHECK_ARG(1, numeric, evalf);
@@ -431,8 +424,8 @@ static ex f_find(const exprseq &e)
        exset found;
        e[0].find(e[1], found);
        lst l;
-       for (exset::const_iterator i = found.begin(); i != found.end(); ++i)
-               l.append(*i);
+       for (auto & i : found)
+               l.append(i);
        return l;
 }
 
@@ -472,7 +465,7 @@ class apply_map_function : public map_function {
 public:
        apply_map_function(const ex & a) : apply(a) {}
        virtual ~apply_map_function() {}
-       ex operator()(const ex & e) { return apply.subs(wild() == e, true); }
+       ex operator()(const ex & e) override { return apply.subs(wild() == e, true); }
 };
 
 static ex f_map(const exprseq &e)
@@ -486,8 +479,8 @@ static ex f_match(const exprseq &e)
        exmap repls;
        if (e[0].match(e[1], repls)) {
                lst repl_lst;
-               for (exmap::const_iterator i = repls.begin(); i != repls.end(); ++i)
-                       repl_lst.append(relational(i->first, i->second, relational::equal));
+               for (auto & i : repls)
+                       repl_lst.append(relational(i.first, i.second, relational::equal));
                return repl_lst;
        }
        throw std::runtime_error("FAIL");
@@ -618,8 +611,6 @@ static const fcn_init builtin_fcns[] = {
        {"diff", f_diff2, 2},
        {"diff", f_diff3, 3},
        {"divide", f_divide, 2},
-       {"eval", f_eval1, 1},
-       {"eval", f_eval2, 2},
        {"evalf", f_evalf1, 1},
        {"evalf", f_evalf2, 2},
        {"evalm", f_evalm, 1},
@@ -729,19 +720,16 @@ static void insert_fcns(const fcn_init *p)
 
 static ex f_ginac_function(const exprseq &es, int serial)
 {
-       return GiNaC::function(serial, es).eval(1);
+       return GiNaC::function(serial, es);
 }
 
 // All registered GiNaC functions
 namespace GiNaC {
 static void ginsh_get_ginac_functions(void)
 {
-       vector<function_options> gfv = function::get_registered_functions();
-       vector<function_options>::const_iterator i = gfv.begin(), end = gfv.end();
        unsigned serial = 0;
-       while (i != end) {
-               fcns.insert(make_pair(i->get_name(), fcn_desc(f_ginac_function, i->get_nparams(), serial)));
-               ++i;
+       for (auto & i : function::get_registered_functions()) {
+               fcns.insert(make_pair(i.get_name(), fcn_desc(f_ginac_function, i.get_nparams(), serial)));
                serial++;
        }
 }
@@ -902,7 +890,7 @@ static void ginsh_readline_init(char* name)
 void greeting(void)
 {
     cout << "ginsh - GiNaC Interactive Shell (GiNaC V" << GINACLIB_VERSION << ")" << endl;
-    cout << "  __,  _______  Copyright (C) 1999-2011 Johannes Gutenberg University Mainz,\n"
+    cout << "  __,  _______  Copyright (C) 1999-2015 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;