1 /** @file parse_context.cpp
3 * Implementation of the parser context. */
6 * GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "parse_context.h"
33 find_or_insert_symbol(const std::string& name, symtab& syms, const bool strict)
35 symtab::const_iterator p = syms.find(name);
36 if (p != syms.end()) {
37 if (is_a<symbol>(p->second))
38 return ex_to<symbol>(p->second);
40 throw std::invalid_argument(
41 std::string("find_or_insert_symbol: name \"")
42 + name + "\" does not correspond to a symbol");
47 throw std::invalid_argument(
48 std::string("find_or_insert_symbol: symbol \"")
49 + name + "\" not found");
51 const symbol sy(name);
56 const prototype_table& get_default_reader(bool force_init)
59 static bool initialized = false;
60 static prototype_table reader;
61 if ( !initialized || force_init ) {
62 std::vector<function_options> flist = function::get_registered_functions();
63 std::vector<function_options>::iterator i = flist.begin(), end = flist.end();
64 for ( ; i != end; ++i ) {
65 std::string name = i->get_name();
66 unsigned narg = i->get_nparams();
67 reader[make_pair(name, narg)] = function::find_function(name, narg);