1 /** @file ginsh_parser.yy
3 * Input grammar definition for ginsh.
4 * This file must be processed with yacc/bison. */
7 * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include <sys/resource.h>
35 #include <sys/types.h>
43 #define YYERROR_VERBOSE 1
45 // Original readline settings
46 static int orig_completion_append_character;
47 static char *orig_basic_word_break_characters;
49 // Expression stack for ", "" and """
50 static void push(const ex &e);
53 // Start and end time for the time() function
54 static struct rusage start_time, end_time;
56 // Table of functions (a multimap, because one function may appear with different
57 // numbers of parameters)
58 typedef ex (*fcnp)(const exprseq &e);
59 typedef ex (*fcnp2)(const exprseq &e, int serial);
62 fcn_desc() : p(NULL), num_params(0) {}
63 fcn_desc(fcnp func, int num) : p(func), num_params(num), is_ginac(false) {}
64 fcn_desc(fcnp2 func, int num, int ser) : p((fcnp)func), num_params(num), is_ginac(true), serial(ser) {}
66 fcnp p; // Pointer to function
67 int num_params; // Number of parameters (0 = arbitrary)
68 bool is_ginac; // Flag: function is GiNaC function
69 int serial; // GiNaC function serial number (if is_ginac == true)
72 typedef multimap<string, fcn_desc> fcn_tab;
75 static fcn_tab::const_iterator find_function(const ex &sym, int req_params);
77 // Table to map help topics to help strings
78 typedef multimap<string, string> help_tab;
81 static void print_help(const string &topic);
82 static void print_help_topics(void);
85 /* Tokens (T_LITERAL means a literal value returned by the parser, but not
86 of class numeric or symbol (e.g. a constant or the FAIL object)) */
87 %token T_NUMBER T_SYMBOL T_LITERAL T_DIGITS T_QUOTE T_QUOTE2 T_QUOTE3
88 %token T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ T_MATRIX_BEGIN T_MATRIX_END
90 %token T_QUIT T_WARRANTY T_PRINT T_IPRINT T_TIME T_XYZZY T_INVENTORY T_LOOK T_SCORE
92 /* Operator precedence and associativity */
95 %left '<' '>' T_LESSEQ T_GREATEREQ
119 } catch (exception &e) {
120 cerr << e.what() << endl;
127 } catch (exception &e) {
128 std::cerr << e.what() << endl;
132 | T_PRINT '(' exp ')' ';' {
134 $3.print(print_tree(std::cout));
135 } catch (exception &e) {
136 std::cerr << e.what() << endl;
140 | T_IPRINT '(' exp ')' ';' {
143 if (!e.info(info_flags::integer))
144 throw (std::invalid_argument("argument to iprint() must be an integer"));
145 long i = ex_to_numeric(e).to_long();
147 cout << "#o" << oct << i << endl;
148 cout << "#x" << hex << i << dec << endl;
149 } catch (exception &e) {
150 cerr << e.what() << endl;
154 | '?' T_SYMBOL {print_help(ex_to_symbol($2).getname());}
155 | '?' T_TIME {print_help("time");}
156 | '?' '?' {print_help_topics();}
159 cout << "This program is free software; you can redistribute it and/or modify it under\n";
160 cout << "the terms of the GNU General Public License as published by the Free Software\n";
161 cout << "Foundation; either version 2 of the License, or (at your option) any later\n";
162 cout << "version.\n";
163 cout << "This program is distributed in the hope that it will be useful, but WITHOUT\n";
164 cout << "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n";
165 cout << "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n";
166 cout << "details.\n";
167 cout << "You should have received a copy of the GNU General Public License along with\n";
168 cout << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n";
169 cout << "Cambridge, MA 02139, USA.\n";
171 | T_XYZZY {cout << "Nothing happens.\n";}
172 | T_INVENTORY {cout << "You're not carrying anything.\n";}
173 | T_LOOK {cout << "You're in a twisty little maze of passages, all alike.\n";}
175 cout << "If you were to quit now, you would score ";
176 cout << (syms.size() > 350 ? 350 : syms.size());
177 cout << " out of a possible 350.\n";
179 | T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' {
180 getrusage(RUSAGE_SELF, &end_time);
181 cout << (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) +
182 (end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) +
183 double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 +
184 double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6 << 's' << endl;
186 | error ';' {yyclearin; yyerrok;}
187 | error ':' {yyclearin; yyerrok;}
190 exp : T_NUMBER {$$ = $1;}
191 | T_SYMBOL {$$ = $1.eval();}
192 | '\'' T_SYMBOL '\'' {$$ = $2;}
193 | T_LITERAL {$$ = $1;}
194 | T_DIGITS {$$ = $1;}
195 | T_QUOTE {$$ = exstack[0];}
196 | T_QUOTE2 {$$ = exstack[1];}
197 | T_QUOTE3 {$$ = exstack[2];}
198 | T_SYMBOL '(' exprseq ')' {
199 fcn_tab::const_iterator i = find_function($1, $3.nops());
200 if (i->second.is_ginac) {
201 $$ = ((fcnp2)(i->second.p))(static_cast<const exprseq &>(*($3.bp)), i->second.serial);
203 $$ = (i->second.p)(static_cast<const exprseq &>(*($3.bp)));
206 | T_DIGITS '=' T_NUMBER {$$ = $3; Digits = ex_to_numeric($3).to_int();}
207 | T_SYMBOL '=' exp {$$ = $3; const_cast<symbol *>(&ex_to_symbol($1))->assign($3);}
208 | exp T_EQUAL exp {$$ = $1 == $3;}
209 | exp T_NOTEQ exp {$$ = $1 != $3;}
210 | exp '<' exp {$$ = $1 < $3;}
211 | exp T_LESSEQ exp {$$ = $1 <= $3;}
212 | exp '>' exp {$$ = $1 > $3;}
213 | exp T_GREATEREQ exp {$$ = $1 >= $3;}
214 | exp '+' exp {$$ = $1 + $3;}
215 | exp '-' exp {$$ = $1 - $3;}
216 | exp '*' exp {$$ = $1 * $3;}
217 | exp '/' exp {$$ = $1 / $3;}
218 | '-' exp %prec NEG {$$ = -$2;}
219 | '+' exp %prec NEG {$$ = $2;}
220 | exp '^' exp {$$ = power($1, $3);}
221 | exp '!' {$$ = factorial($1);}
222 | '(' exp ')' {$$ = $2;}
223 | '[' list_or_empty ']' {$$ = $2;}
224 | T_MATRIX_BEGIN matrix T_MATRIX_END {$$ = lst_to_matrix(ex_to_lst($2));}
227 exprseq : exp {$$ = exprseq($1);}
228 | exprseq ',' exp {exprseq es(static_cast<exprseq &>(*($1.bp))); $$ = es.append($3);}
231 list_or_empty: /* empty */ {$$ = *new lst;}
235 list : exp {$$ = lst($1);}
236 | list ',' exp {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($3);}
239 matrix : T_MATRIX_BEGIN row T_MATRIX_END {$$ = lst($2);}
240 | matrix ',' T_MATRIX_BEGIN row T_MATRIX_END {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($4);}
243 row : exp {$$ = lst($1);}
244 | row ',' exp {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($3);}
253 // Error print routine
256 cerr << s << " at " << yytext << endl;
260 // Push expression "e" onto the expression stack (for ", "" and """)
261 static void push(const ex &e)
263 exstack[2] = exstack[1];
264 exstack[1] = exstack[0];
273 static ex f_denom(const exprseq &e) {return e[0].denom();}
274 static ex f_eval1(const exprseq &e) {return e[0].eval();}
275 static ex f_evalf1(const exprseq &e) {return e[0].evalf();}
276 static ex f_expand(const exprseq &e) {return e[0].expand();}
277 static ex f_gcd(const exprseq &e) {return gcd(e[0], e[1]);}
278 static ex f_lcm(const exprseq &e) {return lcm(e[0], e[1]);}
279 static ex f_lsolve(const exprseq &e) {return lsolve(e[0], e[1]);}
280 static ex f_nops(const exprseq &e) {return e[0].nops();}
281 static ex f_normal1(const exprseq &e) {return e[0].normal();}
282 static ex f_numer(const exprseq &e) {return e[0].numer();}
283 static ex f_pow(const exprseq &e) {return pow(e[0], e[1]);}
284 static ex f_sqrt(const exprseq &e) {return sqrt(e[0]);}
285 static ex f_subs2(const exprseq &e) {return e[0].subs(e[1]);}
287 #define CHECK_ARG(num, type, fcn) if (!is_ex_of_type(e[num], type)) throw(std::invalid_argument("argument " #num " to " #fcn "() must be a " #type))
289 static ex f_charpoly(const exprseq &e)
291 CHECK_ARG(0, matrix, charpoly);
292 CHECK_ARG(1, symbol, charpoly);
293 return ex_to_matrix(e[0]).charpoly(ex_to_symbol(e[1]));
296 static ex f_coeff(const exprseq &e)
298 CHECK_ARG(1, symbol, coeff);
299 CHECK_ARG(2, numeric, coeff);
300 return e[0].coeff(ex_to_symbol(e[1]), ex_to_numeric(e[2]).to_int());
303 static ex f_collect(const exprseq &e)
305 CHECK_ARG(1, symbol, collect);
306 return e[0].collect(ex_to_symbol(e[1]));
309 static ex f_content(const exprseq &e)
311 CHECK_ARG(1, symbol, content);
312 return e[0].content(ex_to_symbol(e[1]));
315 static ex f_degree(const exprseq &e)
317 CHECK_ARG(1, symbol, degree);
318 return e[0].degree(ex_to_symbol(e[1]));
321 static ex f_determinant(const exprseq &e)
323 CHECK_ARG(0, matrix, determinant);
324 return ex_to_matrix(e[0]).determinant();
327 static ex f_diag(const exprseq &e)
329 unsigned dim = e.nops();
330 matrix &m = *new matrix(dim, dim);
331 for (unsigned i=0; i<dim; i++)
332 m.set(i, i, e.op(i));
336 static ex f_diff2(const exprseq &e)
338 CHECK_ARG(1, symbol, diff);
339 return e[0].diff(ex_to_symbol(e[1]));
342 static ex f_diff3(const exprseq &e)
344 CHECK_ARG(1, symbol, diff);
345 CHECK_ARG(2, numeric, diff);
346 return e[0].diff(ex_to_symbol(e[1]), ex_to_numeric(e[2]).to_int());
349 static ex f_divide(const exprseq &e)
352 if (divide(e[0], e[1], q))
358 static ex f_eval2(const exprseq &e)
360 CHECK_ARG(1, numeric, eval);
361 return e[0].eval(ex_to_numeric(e[1]).to_int());
364 static ex f_evalf2(const exprseq &e)
366 CHECK_ARG(1, numeric, evalf);
367 return e[0].evalf(ex_to_numeric(e[1]).to_int());
370 static ex f_has(const exprseq &e)
372 return e[0].has(e[1]) ? ex(1) : ex(0);
375 static ex f_inverse(const exprseq &e)
377 CHECK_ARG(0, matrix, inverse);
378 return ex_to_matrix(e[0]).inverse();
381 static ex f_is(const exprseq &e)
383 CHECK_ARG(0, relational, is);
384 return (bool)ex_to_relational(e[0]) ? ex(1) : ex(0);
387 static ex f_lcoeff(const exprseq &e)
389 CHECK_ARG(1, symbol, lcoeff);
390 return e[0].lcoeff(ex_to_symbol(e[1]));
393 static ex f_ldegree(const exprseq &e)
395 CHECK_ARG(1, symbol, ldegree);
396 return e[0].ldegree(ex_to_symbol(e[1]));
399 static ex f_normal2(const exprseq &e)
401 CHECK_ARG(1, numeric, normal);
402 return e[0].normal(ex_to_numeric(e[1]).to_int());
405 static ex f_op(const exprseq &e)
407 CHECK_ARG(1, numeric, op);
408 int n = ex_to_numeric(e[1]).to_int();
409 if (n < 0 || n >= (int)e[0].nops())
410 throw(std::out_of_range("second argument to op() is out of range"));
414 static ex f_prem(const exprseq &e)
416 CHECK_ARG(2, symbol, prem);
417 return prem(e[0], e[1], ex_to_symbol(e[2]));
420 static ex f_primpart(const exprseq &e)
422 CHECK_ARG(1, symbol, primpart);
423 return e[0].primpart(ex_to_symbol(e[1]));
426 static ex f_quo(const exprseq &e)
428 CHECK_ARG(2, symbol, quo);
429 return quo(e[0], e[1], ex_to_symbol(e[2]));
432 static ex f_rem(const exprseq &e)
434 CHECK_ARG(2, symbol, rem);
435 return rem(e[0], e[1], ex_to_symbol(e[2]));
438 static ex f_series(const exprseq &e)
440 CHECK_ARG(2, numeric, series);
441 return e[0].series(e[1], ex_to_numeric(e[2]).to_int());
444 static ex f_sqrfree1(const exprseq &e)
446 return sqrfree(e[0]);
449 static ex f_sqrfree2(const exprseq &e)
451 CHECK_ARG(1, lst, sqrfree);
452 return sqrfree(e[0], ex_to_lst(e[1]));
455 static ex f_subs3(const exprseq &e)
457 CHECK_ARG(1, lst, subs);
458 CHECK_ARG(2, lst, subs);
459 return e[0].subs(ex_to_lst(e[1]), ex_to_lst(e[2]));
462 static ex f_tcoeff(const exprseq &e)
464 CHECK_ARG(1, symbol, tcoeff);
465 return e[0].tcoeff(ex_to_symbol(e[1]));
468 static ex f_trace(const exprseq &e)
470 CHECK_ARG(0, matrix, trace);
471 return ex_to_matrix(e[0]).trace();
474 static ex f_transpose(const exprseq &e)
476 CHECK_ARG(0, matrix, transpose);
477 return ex_to_matrix(e[0]).transpose();
480 static ex f_unassign(const exprseq &e)
482 CHECK_ARG(0, symbol, unassign);
483 (const_cast<symbol *>(&ex_to_symbol(e[0])))->unassign();
487 static ex f_unit(const exprseq &e)
489 CHECK_ARG(1, symbol, unit);
490 return e[0].unit(ex_to_symbol(e[1]));
493 static ex f_dummy(const exprseq &e)
495 throw(std::logic_error("dummy function called (shouldn't happen)"));
498 // Table for initializing the "fcns" map
504 static const fcn_init builtin_fcns[] = {
505 {"charpoly", fcn_desc(f_charpoly, 2)},
506 {"coeff", fcn_desc(f_coeff, 3)},
507 {"collect", fcn_desc(f_collect, 2)},
508 {"content", fcn_desc(f_content, 2)},
509 {"degree", fcn_desc(f_degree, 2)},
510 {"denom", fcn_desc(f_denom, 1)},
511 {"determinant", fcn_desc(f_determinant, 1)},
512 {"diag", fcn_desc(f_diag, 0)},
513 {"diff", fcn_desc(f_diff2, 2)},
514 {"diff", fcn_desc(f_diff3, 3)},
515 {"divide", fcn_desc(f_divide, 2)},
516 {"eval", fcn_desc(f_eval1, 1)},
517 {"eval", fcn_desc(f_eval2, 2)},
518 {"evalf", fcn_desc(f_evalf1, 1)},
519 {"evalf", fcn_desc(f_evalf2, 2)},
520 {"expand", fcn_desc(f_expand, 1)},
521 {"gcd", fcn_desc(f_gcd, 2)},
522 {"has", fcn_desc(f_has, 2)},
523 {"inverse", fcn_desc(f_inverse, 1)},
524 {"is", fcn_desc(f_is, 1)},
525 {"lcm", fcn_desc(f_lcm, 2)},
526 {"lcoeff", fcn_desc(f_lcoeff, 2)},
527 {"ldegree", fcn_desc(f_ldegree, 2)},
528 {"lsolve", fcn_desc(f_lsolve, 2)},
529 {"nops", fcn_desc(f_nops, 1)},
530 {"normal", fcn_desc(f_normal1, 1)},
531 {"normal", fcn_desc(f_normal2, 2)},
532 {"numer", fcn_desc(f_numer, 1)},
533 {"op", fcn_desc(f_op, 2)},
534 {"pow", fcn_desc(f_pow, 2)},
535 {"prem", fcn_desc(f_prem, 3)},
536 {"primpart", fcn_desc(f_primpart, 2)},
537 {"quo", fcn_desc(f_quo, 3)},
538 {"rem", fcn_desc(f_rem, 3)},
539 {"series", fcn_desc(f_series, 3)},
540 {"sqrfree", fcn_desc(f_sqrfree1, 1)},
541 {"sqrfree", fcn_desc(f_sqrfree2, 2)},
542 {"sqrt", fcn_desc(f_sqrt, 1)},
543 {"subs", fcn_desc(f_subs2, 2)},
544 {"subs", fcn_desc(f_subs3, 3)},
545 {"tcoeff", fcn_desc(f_tcoeff, 2)},
546 {"time", fcn_desc(f_dummy, 0)},
547 {"trace", fcn_desc(f_trace, 1)},
548 {"transpose", fcn_desc(f_transpose, 1)},
549 {"unassign", fcn_desc(f_unassign, 1)},
550 {"unit", fcn_desc(f_unit, 2)},
551 {NULL, fcn_desc(f_dummy, 0)} // End marker
556 * Add functions to ginsh
559 // Functions from fcn_init array
560 static void insert_fcns(const fcn_init *p)
563 fcns.insert(make_pair(string(p->name), p->desc));
568 static ex f_ginac_function(const exprseq &es, int serial)
570 return function(serial, es).eval(1);
573 // All registered GiNaC functions
574 void GiNaC::ginsh_get_ginac_functions(void)
576 vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
579 fcns.insert(make_pair(i->get_name(), fcn_desc(f_ginac_function, i->get_nparams(), serial)));
587 * Find a function given a name and number of parameters. Throw exceptions on error.
590 static fcn_tab::const_iterator find_function(const ex &sym, int req_params)
592 const string &name = ex_to_symbol(sym).getname();
593 typedef fcn_tab::const_iterator I;
594 pair<I, I> b = fcns.equal_range(name);
595 if (b.first == b.second)
596 throw(std::logic_error("unknown function '" + name + "'"));
598 for (I i=b.first; i!=b.second; i++)
599 if ((i->second.num_params == 0) || (i->second.num_params == req_params))
602 throw(std::logic_error("invalid number of arguments to " + name + "()"));
607 * Insert help strings
610 // Normal help string
611 static void insert_help(const char *topic, const char *str)
613 help.insert(make_pair(string(topic), string(str)));
616 // Help string for functions, automatically generates synopsis
617 static void insert_fcn_help(const char *name, const char *str)
619 typedef fcn_tab::const_iterator I;
620 pair<I, I> b = fcns.equal_range(name);
621 if (b.first != b.second) {
622 string help_str = string(name) + "(";
623 for (int i=0; i<b.first->second.num_params; i++) {
626 help_str += "expression";
630 help.insert(make_pair(string(name), help_str));
639 // Help for a given topic
640 static void print_help(const string &topic)
642 typedef help_tab::const_iterator I;
643 pair<I, I> b = help.equal_range(topic);
644 if (b.first == b.second)
645 cout << "no help for '" << topic << "'\n";
647 for (I i=b.first; i!=b.second; i++)
648 cout << i->second << endl;
652 // List of help topics
653 static void print_help_topics(void)
655 cout << "Available help topics:\n";
656 help_tab::const_iterator i;
657 string last_name = string("*");
659 for (i=help.begin(); i!=help.end(); i++) {
660 // Don't print duplicates
661 if (i->first != last_name) {
666 last_name = i->first;
669 cout << "\nTo get help for a certain topic, type ?topic\n";
674 * Function name completion functions for readline
677 static char *fcn_generator(char *text, int state)
679 static int len; // Length of word to complete
680 static fcn_tab::const_iterator index; // Iterator to function being currently considered
682 // If this is a new word to complete, initialize now
684 index = fcns.begin();
688 // Return the next function which partially matches
689 while (index != fcns.end()) {
690 const char *fcn_name = index->first.c_str();
692 if (strncmp(fcn_name, text, len) == 0)
693 return strdup(fcn_name);
698 static char **fcn_completion(char *text, int start, int end)
700 if (rl_line_buffer[0] == '!') {
701 // For shell commands, revert back to filename completion
702 rl_completion_append_character = orig_completion_append_character;
703 rl_basic_word_break_characters = orig_basic_word_break_characters;
704 rl_completer_word_break_characters = rl_basic_word_break_characters;
705 return completion_matches(text, (CPFunction *)filename_completion_function);
707 // Otherwise, complete function names
708 rl_completion_append_character = '(';
709 rl_basic_word_break_characters = " \t\n\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~";
710 rl_completer_word_break_characters = rl_basic_word_break_characters;
711 return completion_matches(text, (CPFunction *)fcn_generator);
717 cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " V" << VERSION << ")" << endl;
718 cout << " __, _______ Copyright (C) 1999-2001 Johannes Gutenberg University Mainz,\n"
719 << " (__) * | Germany. This is free software with ABSOLUTELY NO WARRANTY.\n"
720 << " ._) i N a C | You are welcome to redistribute it under certain conditions.\n"
721 << "<-------------' For details type `warranty;'.\n" << endl;
722 cout << "Type ?? for a list of help topics." << endl;
729 int main(int argc, char **argv)
731 // Print banner in interactive mode
735 // Init function table
736 insert_fcns(builtin_fcns);
737 ginsh_get_ginac_functions();
739 // Init help for operators (automatically generated from man page)
740 insert_help("operators", "Operators in falling order of precedence:");
741 #include "ginsh_op_help.c"
743 // Init help for built-in functions (automatically generated from man page)
744 #include "ginsh_fcn_help.c"
746 // Help for GiNaC functions is added manually
747 insert_fcn_help("acos", "inverse cosine function");
748 insert_fcn_help("acosh", "inverse hyperbolic cosine function");
749 insert_fcn_help("asin", "inverse sine function");
750 insert_fcn_help("asinh", "inverse hyperbolic sine function");
751 insert_fcn_help("atan", "inverse tangent function");
752 insert_fcn_help("atan2", "inverse tangent function with two arguments");
753 insert_fcn_help("atanh", "inverse hyperbolic tangent function");
754 insert_fcn_help("beta", "Beta function");
755 insert_fcn_help("binomial", "binomial function");
756 insert_fcn_help("cos", "cosine function");
757 insert_fcn_help("cosh", "hyperbolic cosine function");
758 insert_fcn_help("exp", "exponential function");
759 insert_fcn_help("factorial", "factorial function");
760 insert_fcn_help("lgamma", "natural logarithm of Gamma function");
761 insert_fcn_help("tgamma", "Gamma function");
762 insert_fcn_help("log", "natural logarithm");
763 insert_fcn_help("psi", "psi function\npsi(x) is the digamma function, psi(n,x) the nth polygamma function");
764 insert_fcn_help("sin", "sine function");
765 insert_fcn_help("sinh", "hyperbolic sine function");
766 insert_fcn_help("tan", "tangent function");
767 insert_fcn_help("tanh", "hyperbolic tangent function");
768 insert_fcn_help("zeta", "zeta function\nzeta(x) is Riemann's zeta function, zeta(n,x) its nth derivative");
769 insert_fcn_help("Li2", "dilogarithm");
770 insert_fcn_help("Li3", "trilogarithm");
771 insert_fcn_help("Order", "order term function (for truncated power series)");
773 // Init readline completer
774 rl_readline_name = argv[0];
775 rl_attempted_completion_function = (CPPFunction *)fcn_completion;
776 orig_completion_append_character = rl_completion_append_character;
777 orig_basic_word_break_characters = rl_basic_word_break_characters;
779 // Init input file list, open first file
780 num_files = argc - 1;
781 file_list = argv + 1;
783 yyin = fopen(*file_list, "r");
785 cerr << "Can't open " << *file_list << endl;
792 // Parse input, catch all remaining exceptions
796 } catch (exception &e) {
797 cerr << e.what() << endl;