From 2c4c27eff885eaf0aec4ff0bc0de40c0531f3c55 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Thu, 18 Nov 1999 20:47:39 +0000 Subject: [PATCH 1/1] - added on-line help system --- ginsh/Makefile.am | 10 ++ ginsh/Makefile.in | 9 ++ ginsh/ginsh.1 | 78 ++++++++-- ginsh/ginsh.h | 3 + ginsh/ginsh_fcn_help.sed | 33 ++++ ginsh/ginsh_lexer.ll | 2 - ginsh/ginsh_op_help.sed | 18 +++ ginsh/ginsh_parser.yy | 326 ++++++++++++++++++++++++++------------- 8 files changed, 361 insertions(+), 118 deletions(-) create mode 100644 ginsh/ginsh_fcn_help.sed create mode 100644 ginsh/ginsh_op_help.sed diff --git a/ginsh/Makefile.am b/ginsh/Makefile.am index f252a029..0cdab1d5 100644 --- a/ginsh/Makefile.am +++ b/ginsh/Makefile.am @@ -1,7 +1,17 @@ ## Process this file with automake to produce Makefile.in + bin_PROGRAMS = ginsh ginsh_SOURCES = ginsh_parser.yy ginsh_lexer.ll ginsh.h ginsh_LDADD = ../ginac/libginac.la $(GINSH_LIBS) man_MANS = ginsh.1 YFLAGS = -d EXTRA_DIST = ginsh_parser.h + +# files created by sed scripts +ginsh_fcn_help.c: ginsh.1 ginsh_fcn_help.sed + sed -n -f ginsh_fcn_help.sed <$< >$@ + +ginsh_op_help.c: ginsh.1 ginsh_op_help.sed + sed -n -f ginsh_op_help.sed <$< >$@ + +ginsh_parser.cc: ginsh_fcn_help.c ginsh_op_help.c diff --git a/ginsh/Makefile.in b/ginsh/Makefile.in index 680dd55d..aeea2f46 100644 --- a/ginsh/Makefile.in +++ b/ginsh/Makefile.in @@ -408,6 +408,15 @@ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean +# files created by sed scripts +ginsh_fcn_help.c: ginsh.1 ginsh_fcn_help.sed + sed -n -f ginsh_fcn_help.sed <$< >$@ + +ginsh_op_help.c: ginsh.1 ginsh_op_help.sed + sed -n -f ginsh_op_help.sed <$< >$@ + +ginsh_parser.cc: ginsh_fcn_help.c ginsh_op_help.c + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/ginsh/ginsh.1 b/ginsh/ginsh.1 index fbe21f4f..32b0cec6 100644 --- a/ginsh/ginsh.1 +++ b/ginsh/ginsh.1 @@ -111,6 +111,7 @@ expression. ginsh provides the following operators, listed in falling order of precedence: .RS .TP 8m +\" GINSH_OP_HELP_START .B ! postfix factorial .TP @@ -158,6 +159,7 @@ not equal .TP .B = symbol assignment +\" GINSH_OP_HELP_END .RE .PP All binary operators are left-associative, with the exception of @@ -213,94 +215,133 @@ respective GiNaC methods of the same name, so I will not describe them in detail here. Please refer to the GiNaC documentation. .PP .RS +\" GINSH_FCN_HELP_START .BI beta( expression ", " expression ) +\- beta function .br .BI charpoly( matrix ", " symbol ) +\- characteristic polynomial of a matrix .br .BI coeff( expression ", " symbol ", " number ) +\- extracts coefficient of symbol^number from a polynomial .br .BI collect( expression ", " symbol ) +\- collects coefficients of like powers .br .BI content( expression ", " symbol ) +\- content part of a polynomial .br .BI degree( expression ", " symbol ) +\- degree of a polynomial .br .BI denom( expression ) +\- denominator of a rational function .br .BI determinant( matrix ) +\- determinant of a matrix .br .BI diag( expression... ) +\- constructs diagonal matrix .br .BI diff( expression ", " "symbol [" ", " number] ) +\- partial differentiation .br .BI divide( expression ", " expression ) +\- exact polynomial division .br -.BI eval( "expression [" ", " number] ) +.BI eval( "expression [" ", " level] ) +\- evaluates an expression, replacing symbols by their assigned value .br -.BI evalf( "expression [" ", " number] ) +.BI evalf( "expression [" ", " level] ) +\- evaluates an expression to a floating point number .br .BI expand( expression ) +\- expands an expression .br .BI gcd( expression ", " expression ) +\- greatest common divisor .br .BI has( expression ", " expression ) +\- returns "1" if the first expression contains the second as a subexpression, "0" otherwise .br .BI inverse( matrix ) +\- inverse of a matrix .br .BI is( relation ) -\- returns "1" if the -.I relation -is true, "0" otherwise (false or undecided) +\- returns "1" if the relation is true, "0" otherwise (false or undecided) .br .BI lcm( expression ", " expression ) +\- least common multiple .br .BI lcoeff( expression ", " symbol ) +\- leading coefficient of a polynomial .br .BI ldegree( expression ", " symbol ) +\- low degree of a polynomial .br -.BI lsolve( list ", " list ) +.BI lsolve( equation-list ", " symbol-list ) +\- solve system of linear equations .br .BI nops( expression ) +\- number of operands in expression .br -.BI normal( "expression [" ", " number] ) +.BI normal( "expression [" ", " level] ) +\- rational function normalization .br .BI numer( expression ) +\- numerator of a rational function .br .BI op( expression ", " number ) +\- extract operand from expression .br -.BI power( expression ", " expression ) +.BI power( expr1 ", " expr2 ) +\- exponentiation (equivalent to writing expr1^expr2) .br .BI prem( expression ", " expression ", " symbol ) +\- pseudo-remainder of polynomials .br .BI primpart( expression ", " symbol ) +\- primitive part of a polynomial .br .BI quo( expression ", " expression ", " symbol ) +\- quotient of polynomials .br .BI rem( expression ", " expression ", " symbol ) +\- remainder of polynomials .br -.BI series( expression ", " "symbol [" ", " "number [" ", " number]] ) +.BI series( expression ", " "symbol [" ", " "point [" ", " order]] ) +\- series expansion .br .BI sqrfree( expression ", " symbol ) +\- square-free factorization of a polynomial .br .BI sqrt( expression ) +\- square root .br .BI subs( expression ", " relation-or-list ) .br -.BI subs( expression ", " list ", " list ) +.BI subs( expression ", " look-for-list ", " replace-by-list ) +\- substitute subexpressions .br .BI tcoeff( expression ", " symbol ) +\- trailing coefficient of a polynomial .br .BI time( expression ) -\- returns the time in seconds needed to evaluate the given -.I expression +\- returns the time in seconds needed to evaluate the given expression .br .BI trace( matrix ) +\- trace of a matrix .br .BI transpose( matrix ) +\- transpose of a matrix .br .BI unassign( symbol ) +\- unassign an assigned symbol .br .BI unit( expression ", " symbol ) +\- unit part of a polynomial +.br +\" GINSH_FCN_HELP_END .RE .SS SPECIAL COMMANDS To exit ginsh, enter @@ -312,6 +353,17 @@ or .B exit .RE .PP +ginsh can display a (short) help for a given topic (mostly about functions +and operators) by entering +.RS +.BI ? topic +.RE +Typing +.RS +.B ?? +.RE +will display a list of available help topics. +.PP The command .RS .BI print( expression ); @@ -365,6 +417,8 @@ x \-2*d\-2*x*c\-x^2*c\-x*d+x^2*d\-c > collect(", x); (\-d\-2*c)*x+(d\-c)*x^2\-2*d\-c +> solve quantum field theory; +parse error at quantum > quit .fi .SH DIAGNOSTICS diff --git a/ginsh/ginsh.h b/ginsh/ginsh.h index bd65a6a7..c225fb09 100644 --- a/ginsh/ginsh.h +++ b/ginsh/ginsh.h @@ -26,6 +26,9 @@ #include #include +#include +#include + #ifdef HAVE_READLINE_READLINE_H extern "C" { #include diff --git a/ginsh/ginsh_fcn_help.sed b/ginsh/ginsh_fcn_help.sed new file mode 100644 index 00000000..0aa2f926 --- /dev/null +++ b/ginsh/ginsh_fcn_help.sed @@ -0,0 +1,33 @@ +# Convert help for ginsh functions from man page to C source +/GINSH_FCN_HELP_START/,/GINSH_FCN_HELP_END/{ + +# .BI lines contain the function synopsis +/\.BI/{ + +# extract function name +h +s/\.BI \(.*\)(.*/insert_help("\1",/p +g + +# extract synopsis +s/"//g +s/ , /,/g +s/\.BI /"/ +s/( /(/ +s/ )/)"/ +p +# handle multi-line synopsis +s/.br/);/p +} + +# \- lines contain the function description +/\\-/{ +s/"/'/g +s/\\-/" -/ +s/$/"/ +p +} + +# .br lines start the next function +/.br/s//);/p +} diff --git a/ginsh/ginsh_lexer.ll b/ginsh/ginsh_lexer.ll index 961c8564..293e46b5 100644 --- a/ginsh/ginsh_lexer.ll +++ b/ginsh/ginsh_lexer.ll @@ -28,8 +28,6 @@ %{ #include "config.h" -#include - #include "ginsh.h" #include "ginsh_parser.h" diff --git a/ginsh/ginsh_op_help.sed b/ginsh/ginsh_op_help.sed new file mode 100644 index 00000000..8ca265a0 --- /dev/null +++ b/ginsh/ginsh_op_help.sed @@ -0,0 +1,18 @@ +# Convert help for ginsh operators from man page to C source +/GINSH_OP_HELP_START/,/GINSH_OP_HELP_END/{ + +# .B lines contain the operator symbol +/.B/{ + +# extract operator symbol +s/.B \(.*\)/insert_help("operators","\1\\t"/ +s/\\-/-/g +p + +# next line contains description +n +s/^/"/ +s/$/");/ +p +} +} diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index 99478df7..fdc9ac30 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -35,8 +35,6 @@ #include #endif -#include -#include #include #include "ginsh.h" @@ -73,6 +71,13 @@ static fcn_tab fcns; static fcn_tab::const_iterator find_function(const ex &sym, int req_params); +// Table to map help topics to help strings +typedef multimap help_tab; +static help_tab help; + +static void print_help(const string &topic); +static void print_help_topics(void); + static ex lst2matrix(const ex &l); %} @@ -106,44 +111,42 @@ input : /* empty */ ; line : ';' - | exp ';' - { - try { - cout << $1 << endl; - push($1); - } catch (exception &e) { - cerr << e.what() << endl; - YYERROR; - } + | exp ';' { + try { + cout << $1 << endl; + push($1); + } catch (exception &e) { + cerr << e.what() << endl; + YYERROR; } - | exp ':' - { - try { - push($1); - } catch (exception &e) { - cerr << e.what() << endl; - YYERROR; - } + } + | exp ':' { + try { + push($1); + } catch (exception &e) { + cerr << e.what() << endl; + YYERROR; } - | T_PRINT '(' exp ')' ';' - { - try { - $3.printtree(cout); - } catch (exception &e) { - cerr << e.what() << endl; - YYERROR; - } + } + | T_PRINT '(' exp ')' ';' { + try { + $3.printtree(cout); + } catch (exception &e) { + cerr << e.what() << endl; + YYERROR; } + } + | '?' T_SYMBOL {print_help(ex_to_symbol($2).getname());} + | '?' '?' {print_help_topics();} | T_QUIT {YYACCEPT;} | T_XYZZY {cout << "Nothing happens.\n";} | T_INVENTORY {cout << "You're not carrying anything.\n";} | T_LOOK {cout << "You're in a twisty little maze of passages, all alike.\n";} - | T_SCORE - { - cout << "If you were to quit now, you would score "; - cout << (syms.size() > 350 ? 350 : syms.size()); - cout << " out of a possible 350.\n"; - } + | T_SCORE { + cout << "If you were to quit now, you would score "; + cout << (syms.size() > 350 ? 350 : syms.size()); + cout << " out of a possible 350.\n"; + } | error ';' {yyclearin; yyerrok;} | error ':' {yyclearin; yyerrok;} ; @@ -156,27 +159,23 @@ exp : T_NUMBER {$$ = $1;} | T_QUOTE {$$ = exstack[0];} | T_QUOTE2 {$$ = exstack[1];} | T_QUOTE3 {$$ = exstack[2];} - | T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' - { - getrusage(RUSAGE_SELF, &end_time); - $$ = (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) + - (end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) + - double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 + - double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6; - } - | T_SYMBOL '(' exprseq ')' - { - fcn_tab::const_iterator i = find_function($1, $3.nops()); - if (i->second.is_ginac) { - $$ = ((fcnp2)(i->second.p))(static_cast(*($3.bp)), i->second.serial); - } else { - $$ = (i->second.p)(static_cast(*($3.bp))); - } + | T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' { + getrusage(RUSAGE_SELF, &end_time); + $$ = (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) + + (end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) + + double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 + + double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6; + } + | T_SYMBOL '(' exprseq ')' { + fcn_tab::const_iterator i = find_function($1, $3.nops()); + if (i->second.is_ginac) { + $$ = ((fcnp2)(i->second.p))(static_cast(*($3.bp)), i->second.serial); + } else { + $$ = (i->second.p)(static_cast(*($3.bp))); } - | T_DIGITS '=' T_NUMBER - {$$ = $3; Digits = ex_to_numeric($3).to_int();} - | T_SYMBOL '=' exp - {$$ = $3; const_cast(&ex_to_symbol($1))->assign($3);} + } + | T_DIGITS '=' T_NUMBER {$$ = $3; Digits = ex_to_numeric($3).to_int();} + | T_SYMBOL '=' exp {$$ = $3; const_cast(&ex_to_symbol($1))->assign($3);} | exp T_EQUAL exp {$$ = $1 == $3;} | exp T_NOTEQ exp {$$ = $1 != $3;} | exp '<' exp {$$ = $1 < $3;} @@ -477,16 +476,84 @@ static ex f_dummy(const exprseq &e) throw(std::logic_error("dummy function called (shouldn't happen)")); } +// Table for initializing the "fcns" map +struct fcn_init { + const char *name; + const fcn_desc &desc; +}; + +static const fcn_init builtin_fcns[] = { + {"beta", fcn_desc(f_beta, 2)}, + {"charpoly", fcn_desc(f_charpoly, 2)}, + {"coeff", fcn_desc(f_coeff, 3)}, + {"collect", fcn_desc(f_collect, 2)}, + {"content", fcn_desc(f_content, 2)}, + {"degree", fcn_desc(f_degree, 2)}, + {"denom", fcn_desc(f_denom, 1)}, + {"determinant", fcn_desc(f_determinant, 1)}, + {"diag", fcn_desc(f_diag, 0)}, + {"diff", fcn_desc(f_diff2, 2)}, + {"diff", fcn_desc(f_diff3, 3)}, + {"divide", fcn_desc(f_divide, 2)}, + {"eval", fcn_desc(f_eval1, 1)}, + {"eval", fcn_desc(f_eval2, 2)}, + {"evalf", fcn_desc(f_evalf1, 1)}, + {"evalf", fcn_desc(f_evalf2, 2)}, + {"expand", fcn_desc(f_expand, 1)}, + {"gcd", fcn_desc(f_gcd, 2)}, + {"has", fcn_desc(f_has, 2)}, + {"inverse", fcn_desc(f_inverse, 1)}, + {"is", fcn_desc(f_is, 1)}, + {"lcm", fcn_desc(f_lcm, 2)}, + {"lcoeff", fcn_desc(f_lcoeff, 2)}, + {"ldegree", fcn_desc(f_ldegree, 2)}, + {"lsolve", fcn_desc(f_lsolve, 2)}, + {"nops", fcn_desc(f_nops, 1)}, + {"normal", fcn_desc(f_normal1, 1)}, + {"normal", fcn_desc(f_normal2, 2)}, + {"numer", fcn_desc(f_numer, 1)}, + {"op", fcn_desc(f_op, 2)}, + {"power", fcn_desc(f_power, 2)}, + {"prem", fcn_desc(f_prem, 3)}, + {"primpart", fcn_desc(f_primpart, 2)}, + {"quo", fcn_desc(f_quo, 3)}, + {"rem", fcn_desc(f_rem, 3)}, + {"series", fcn_desc(f_series2, 2)}, + {"series", fcn_desc(f_series3, 3)}, + {"series", fcn_desc(f_series4, 4)}, + {"sqrfree", fcn_desc(f_sqrfree, 2)}, + {"sqrt", fcn_desc(f_sqrt, 1)}, + {"subs", fcn_desc(f_subs2, 2)}, + {"subs", fcn_desc(f_subs3, 3)}, + {"tcoeff", fcn_desc(f_tcoeff, 2)}, + {"time", fcn_desc(f_dummy, 0)}, + {"trace", fcn_desc(f_trace, 1)}, + {"transpose", fcn_desc(f_transpose, 1)}, + {"unassign", fcn_desc(f_unassign, 1)}, + {"unit", fcn_desc(f_unit, 2)}, + {NULL, fcn_desc(f_unit, 0)} // End marker +}; + /* - * Add all registered GiNaC functions to ginsh + * Add functions to ginsh */ +// Functions from fcn_init array +static void insert_fcns(const fcn_init *p) +{ + while (p->name) { + fcns.insert(make_pair(string(p->name), p->desc)); + p++; + } +} + static ex f_ginac_function(const exprseq &es, int serial) { return function(serial, es).eval(1); } +// All registered GiNaC functions void GiNaC::ginsh_get_ginac_functions(void) { vector::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end(); @@ -519,6 +586,73 @@ static fcn_tab::const_iterator find_function(const ex &sym, int req_params) } +/* + * Insert help strings + */ + +// Normal help string +static void insert_help(const char *topic, const char *str) +{ + help.insert(make_pair(string(topic), string(str))); +} + +// Help string for functions, automatically generates synopsis +static void insert_fcn_help(const char *name, const char *str) +{ + typedef fcn_tab::const_iterator I; + pair b = fcns.equal_range(name); + if (b.first != b.second) { + string help_str = string(name) + "("; + for (int i=0; isecond.num_params; i++) { + if (i) + help_str += ", "; + help_str += "expression"; + } + help_str += ") - "; + help_str += str; + help.insert(make_pair(string(name), help_str)); + } +} + + +/* + * Print help to cout + */ + +// Help for a given topic +static void print_help(const string &topic) +{ + typedef help_tab::const_iterator I; + pair b = help.equal_range(topic); + if (b.first == b.second) + cout << "no help for '" << topic << "'\n"; + else { + for (I i=b.first; i!=b.second; i++) + cout << i->second << endl; + } +} + +// List of help topics +static void print_help_topics(void) +{ + cout << "Available help topics:\n"; + help_tab::const_iterator i; + string last_name = string("*"); + int num = 0; + for (i=help.begin(); i!=help.end(); i++) { + // Don't print duplicates + if (i->first != last_name) { + if (num) + cout << ", "; + num++; + cout << i->first; + last_name = i->first; + } + } + cout << "\nTo get help for a certain topic, type ?topic\n"; +} + + /* * Convert list of lists to matrix */ @@ -598,60 +732,44 @@ int main(int argc, char **argv) cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " " << VERSION << ")\n"; cout << "Copyright (C) 1999 Johannes Gutenberg Universitaet Mainz, Germany\n"; cout << "This is free software, and you are welcome to redistribute it\n"; - cout << "under certain conditions; see the file COPYING for details.\n"; + cout << "under certain conditions; see the file COPYING for details.\n"; + cout << "Type ?? for a list of help topics.\n"; } - // Init table of built-in functions - fcns.insert(make_pair(string("beta"), fcn_desc(f_beta, 2))); - fcns.insert(make_pair(string("charpoly"), fcn_desc(f_charpoly, 2))); - fcns.insert(make_pair(string("coeff"), fcn_desc(f_coeff, 3))); - fcns.insert(make_pair(string("collect"), fcn_desc(f_collect, 2))); - fcns.insert(make_pair(string("content"), fcn_desc(f_content, 2))); - fcns.insert(make_pair(string("degree"), fcn_desc(f_degree, 2))); - fcns.insert(make_pair(string("denom"), fcn_desc(f_denom, 1))); - fcns.insert(make_pair(string("determinant"), fcn_desc(f_determinant, 1))); - fcns.insert(make_pair(string("diag"), fcn_desc(f_diag, 0))); - fcns.insert(make_pair(string("diff"), fcn_desc(f_diff2, 2))); - fcns.insert(make_pair(string("diff"), fcn_desc(f_diff3, 3))); - fcns.insert(make_pair(string("divide"), fcn_desc(f_divide, 2))); - fcns.insert(make_pair(string("eval"), fcn_desc(f_eval1, 1))); - fcns.insert(make_pair(string("eval"), fcn_desc(f_eval2, 2))); - fcns.insert(make_pair(string("evalf"), fcn_desc(f_evalf1, 1))); - fcns.insert(make_pair(string("evalf"), fcn_desc(f_evalf2, 2))); - fcns.insert(make_pair(string("expand"), fcn_desc(f_expand, 1))); - fcns.insert(make_pair(string("gcd"), fcn_desc(f_gcd, 2))); - fcns.insert(make_pair(string("has"), fcn_desc(f_has, 2))); - fcns.insert(make_pair(string("inverse"), fcn_desc(f_inverse, 1))); - fcns.insert(make_pair(string("is"), fcn_desc(f_is, 1))); - fcns.insert(make_pair(string("lcm"), fcn_desc(f_lcm, 2))); - fcns.insert(make_pair(string("lcoeff"), fcn_desc(f_lcoeff, 2))); - fcns.insert(make_pair(string("ldegree"), fcn_desc(f_ldegree, 2))); - fcns.insert(make_pair(string("lsolve"), fcn_desc(f_lsolve, 2))); - fcns.insert(make_pair(string("nops"), fcn_desc(f_nops, 1))); - fcns.insert(make_pair(string("normal"), fcn_desc(f_normal1, 1))); - fcns.insert(make_pair(string("normal"), fcn_desc(f_normal2, 2))); - fcns.insert(make_pair(string("numer"), fcn_desc(f_numer, 1))); - fcns.insert(make_pair(string("op"), fcn_desc(f_op, 2))); - fcns.insert(make_pair(string("power"), fcn_desc(f_power, 2))); - fcns.insert(make_pair(string("prem"), fcn_desc(f_prem, 3))); - fcns.insert(make_pair(string("primpart"), fcn_desc(f_primpart, 2))); - fcns.insert(make_pair(string("quo"), fcn_desc(f_quo, 3))); - fcns.insert(make_pair(string("rem"), fcn_desc(f_rem, 3))); - fcns.insert(make_pair(string("series"), fcn_desc(f_series2, 2))); - fcns.insert(make_pair(string("series"), fcn_desc(f_series3, 3))); - fcns.insert(make_pair(string("series"), fcn_desc(f_series4, 4))); - fcns.insert(make_pair(string("sqrfree"), fcn_desc(f_sqrfree, 2))); - fcns.insert(make_pair(string("sqrt"), fcn_desc(f_sqrt, 1))); - fcns.insert(make_pair(string("subs"), fcn_desc(f_subs2, 2))); - fcns.insert(make_pair(string("subs"), fcn_desc(f_subs3, 3))); - fcns.insert(make_pair(string("tcoeff"), fcn_desc(f_tcoeff, 2))); - fcns.insert(make_pair(string("time"), fcn_desc(f_dummy, 0))); - fcns.insert(make_pair(string("trace"), fcn_desc(f_trace, 1))); - fcns.insert(make_pair(string("transpose"), fcn_desc(f_transpose, 1))); - fcns.insert(make_pair(string("unassign"), fcn_desc(f_unassign, 1))); - fcns.insert(make_pair(string("unit"), fcn_desc(f_unit, 2))); + // Init function table + insert_fcns(builtin_fcns); ginsh_get_ginac_functions(); + // Init help for operators (automatically generated from man page) + insert_help("operators", "Operators in falling order of precedence:"); +#include "ginsh_op_help.c" + + // Init help for built-in functions (automatically generated from man page) +#include "ginsh_fcn_help.c" + + // Help for GiNaC functions is added manually + insert_fcn_help("acos", "inverse cosine function"); + insert_fcn_help("acosh", "inverse hyperbolic cosine function"); + insert_fcn_help("asin", "inverse sine function"); + insert_fcn_help("asinh", "inverse hyperbolic sine function"); + insert_fcn_help("atan", "inverse tangent function"); + insert_fcn_help("atan2", "inverse tangent function with two arguments"); + insert_fcn_help("atanh", "inverse hyperbolic tangent function"); + insert_fcn_help("cos", "cosine function"); + insert_fcn_help("cosh", "hyperbolic cosine function"); + insert_fcn_help("sin", "sine function"); + insert_fcn_help("sinh", "hyperbolic sine function"); + insert_fcn_help("tan", "tangent function"); + insert_fcn_help("tanh", "hyperbolic tangent function"); + insert_fcn_help("exp", "exponential function"); + insert_fcn_help("log", "natural logarithm"); + insert_fcn_help("Li2", "dilogarithm"); + insert_fcn_help("Li3", "trilogarithm"); + insert_fcn_help("binomial", "binomial function"); + insert_fcn_help("factorial", "factorial function"); + insert_fcn_help("gamma", "gamma function"); + insert_fcn_help("Order", "order term function (for truncated power series)"); + // Init readline completer rl_readline_name = argv[0]; rl_attempted_completion_function = (CPPFunction *)fcn_completion; -- 2.44.0