]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.yy
* Preliminar update over Debian's ginac_1.1.3-1.diff.gz.
[ginac.git] / ginsh / ginsh_parser.yy
index c22eafe8e6f0cfdcb7f81c078e7727fadbfbd299..5dc2228ba630a3e45e968f8a1ffc52184bbc6446 100644 (file)
@@ -50,7 +50,7 @@ static char *orig_basic_word_break_characters;
 static const char *orig_basic_word_break_characters;
 #endif
 
-// Expression stack for ", "" and """
+// Expression stack for %, %% and %%%
 static void push(const ex &e);
 static ex exstack[3];
 
@@ -175,6 +175,10 @@ line       : ';'
        }
        | '?' T_SYMBOL          {print_help(ex_to<symbol>($2).get_name());}
        | '?' T_TIME            {print_help("time");}
+       | '?' T_PRINT           {print_help("print");}
+       | '?' T_IPRINT          {print_help("iprint");}
+       | '?' T_PRINTLATEX      {print_help("print_latex");}
+       | '?' T_PRINTCSRC       {print_help("print_csrc");}
        | '?' '?'               {print_help_topics();}
        | T_QUIT                {YYACCEPT;}
        | T_WARRANTY {
@@ -322,8 +326,7 @@ static ex f_tcoeff(const exprseq &e) {return e[0].tcoeff(e[1]);}
 static ex f_charpoly(const exprseq &e)
 {
        CHECK_ARG(0, matrix, charpoly);
-       CHECK_ARG(1, symbol, charpoly);
-       return ex_to<matrix>(e[0]).charpoly(ex_to<symbol>(e[1]));
+       return ex_to<matrix>(e[0]).charpoly(e[1]);
 }
 
 static ex f_coeff(const exprseq &e)
@@ -334,14 +337,12 @@ static ex f_coeff(const exprseq &e)
 
 static ex f_content(const exprseq &e)
 {
-       CHECK_ARG(1, symbol, content);
-       return e[0].content(ex_to<symbol>(e[1]));
+       return e[0].content(e[1]);
 }
 
 static ex f_decomp_rational(const exprseq &e)
 {
-       CHECK_ARG(1, symbol, decomp_rational);
-       return decomp_rational(e[0], ex_to<symbol>(e[1]));
+       return decomp_rational(e[0], e[1]);
 }
 
 static ex f_determinant(const exprseq &e)
@@ -352,9 +353,9 @@ static ex f_determinant(const exprseq &e)
 
 static ex f_diag(const exprseq &e)
 {
-       unsigned dim = e.nops();
+       size_t dim = e.nops();
        matrix &m = *new matrix(dim, dim);
-       for (unsigned i=0; i<dim; i++)
+       for (size_t i=0; i<dim; i++)
                m.set(i, i, e.op(i));
        return m;
 }
@@ -452,26 +453,22 @@ static ex f_op(const exprseq &e)
 
 static ex f_prem(const exprseq &e)
 {
-       CHECK_ARG(2, symbol, prem);
-       return prem(e[0], e[1], ex_to<symbol>(e[2]));
+       return prem(e[0], e[1], e[2]);
 }
 
 static ex f_primpart(const exprseq &e)
 {
-       CHECK_ARG(1, symbol, primpart);
-       return e[0].primpart(ex_to<symbol>(e[1]));
+       return e[0].primpart(e[1]);
 }
 
 static ex f_quo(const exprseq &e)
 {
-       CHECK_ARG(2, symbol, quo);
-       return quo(e[0], e[1], ex_to<symbol>(e[2]));
+       return quo(e[0], e[1], e[2]);
 }
 
 static ex f_rem(const exprseq &e)
 {
-       CHECK_ARG(2, symbol, rem);
-       return rem(e[0], e[1], ex_to<symbol>(e[2]));
+       return rem(e[0], e[1], e[2]);
 }
 
 static ex f_series(const exprseq &e)
@@ -482,8 +479,7 @@ static ex f_series(const exprseq &e)
 
 static ex f_sprem(const exprseq &e)
 {
-       CHECK_ARG(2, symbol, sprem);
-       return sprem(e[0], e[1], ex_to<symbol>(e[2]));
+       return sprem(e[0], e[1], e[2]);
 }
 
 static ex f_sqrfree2(const exprseq &e)
@@ -520,8 +516,7 @@ static ex f_unassign(const exprseq &e)
 
 static ex f_unit(const exprseq &e)
 {
-       CHECK_ARG(1, symbol, unit);
-       return e[0].unit(ex_to<symbol>(e[1]));
+       return e[0].unit(e[1]);
 }
 
 static ex f_dummy(const exprseq &e)
@@ -561,6 +556,7 @@ static const fcn_init builtin_fcns[] = {
        {"gcd", f_gcd, 2},
        {"has", f_has, 2},
        {"inverse", f_inverse, 1},
+       {"iprint", f_dummy, 0},      // for Tab-completion
        {"is", f_is, 1},
        {"lcm", f_lcm, 2},
        {"lcoeff", f_lcoeff, 2},
@@ -577,6 +573,9 @@ static const fcn_init builtin_fcns[] = {
        {"pow", f_pow, 2},
        {"prem", f_prem, 3},
        {"primpart", f_primpart, 2},
+       {"print", f_dummy, 0},       // for Tab-completion
+       {"print_csrc", f_dummy, 0},  // for Tab-completion
+       {"print_latex", f_dummy, 0}, // for Tab-completion
        {"quo", f_quo, 3},
        {"rem", f_rem, 3},
        {"series", f_series, 3},
@@ -587,12 +586,12 @@ static const fcn_init builtin_fcns[] = {
        {"subs", f_subs2, 2},
        {"subs", f_subs3, 3},
        {"tcoeff", f_tcoeff, 2},
-       {"time", f_dummy, 0},
+       {"time", f_dummy, 0},        // for Tab-completion
        {"trace", f_trace, 1},
        {"transpose", f_transpose, 1},
        {"unassign", f_unassign, 1},
        {"unit", f_unit, 2},
-       {NULL, f_dummy, 0}      // End marker
+       {NULL, f_dummy, 0}           // End marker
 };
 
 struct fcn_help_init {
@@ -625,6 +624,10 @@ static const fcn_help_init builtin_help[] = {
        {"zeta", "zeta function\nzeta(x) is Riemann's zeta function, zeta(n,x) its nth derivative"},
        {"Li2", "dilogarithm"},
        {"Li3", "trilogarithm"},
+       {"Li", "(multiple) polylogarithm"},
+       {"S", "Nielsen's generalized polylogarithm"},
+       {"H", "harmonic polylogarithm"},
+       {"mZeta", "multiple zeta value"},
        {"Order", "order term function (for truncated power series)"},
        {"Derivative", "inert differential operator"},
        {NULL, NULL}    // End marker
@@ -846,6 +849,12 @@ int main(int argc, char **argv)
        insert_help(builtin_help);
        insert_help(extended_help);
 
+       // Help for other keywords
+       insert_help("print", "print(expression) - dumps the internal structure of the given expression (for debugging)");
+       insert_help("iprint", "iprint(expression) - prints the given integer expression in decimal, octal, and hexadecimal bases");
+       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");
+
        // Init readline completer
        rl_readline_name = argv[0];
 #if (GINAC_RL_VERSION_MAJOR < 4) || (GINAC_RL_VERSION_MAJOR == 4 && GINAC_RL_VERSION_MINOR < 2)