]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.yy
documentation update
[ginac.git] / ginsh / ginsh_parser.yy
index dcb24ab8cf094d32c980dba041361d7535d1fc4f..faaafcacca4e1ab2ca6bf8cd8a081a9989089786 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with yacc/bison. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 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
@@ -92,14 +92,15 @@ static void print_help_topics(void);
 %token T_NUMBER T_SYMBOL T_LITERAL T_DIGITS T_QUOTE T_QUOTE2 T_QUOTE3
 %token T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ
 
-%token T_QUIT T_WARRANTY T_PRINT T_IPRINT T_TIME T_XYZZY T_INVENTORY T_LOOK T_SCORE
+%token T_QUIT T_WARRANTY T_PRINT T_IPRINT T_PRINTLATEX T_PRINTCSRC T_TIME
+%token T_XYZZY T_INVENTORY T_LOOK T_SCORE
 
 /* Operator precedence and associativity */
 %right '='
 %left T_EQUAL T_NOTEQ
 %left '<' '>' T_LESSEQ T_GREATEREQ
 %left '+' '-'
-%left '*' '/' '%'
+%left '*' '/'
 %nonassoc NEG
 %right '^'
 %nonassoc '!'
@@ -156,6 +157,22 @@ line       : ';'
                        YYERROR;
                }
        }
+       | T_PRINTLATEX '(' exp ')' ';' {
+               try {
+                       $3.print(print_latex(std::cout)); cout << endl;
+               } catch (exception &e) {
+                       std::cerr << e.what() << endl;
+                       YYERROR;
+               }
+       }
+       | T_PRINTCSRC '(' exp ')' ';' {
+               try {
+                       $3.print(print_csrc_double(std::cout)); cout << endl;
+               } catch (exception &e) {
+                       std::cerr << e.what() << endl;
+                       YYERROR;
+               }
+       }
        | '?' T_SYMBOL          {print_help(ex_to<symbol>($2).get_name());}
        | '?' T_TIME            {print_help("time");}
        | '?' '?'               {print_help_topics();}
@@ -462,6 +479,12 @@ static ex f_series(const exprseq &e)
        return e[0].series(e[1], ex_to<numeric>(e[2]).to_int());
 }
 
+static ex f_sprem(const exprseq &e)
+{
+       CHECK_ARG(2, symbol, sprem);
+       return sprem(e[0], e[1], ex_to<symbol>(e[2]));
+}
+
 static ex f_sqrfree2(const exprseq &e)
 {
        CHECK_ARG(1, lst, sqrfree);
@@ -554,6 +577,7 @@ static const fcn_init builtin_fcns[] = {
        {"quo", fcn_desc(f_quo, 3)},
        {"rem", fcn_desc(f_rem, 3)},
        {"series", fcn_desc(f_series, 3)},
+       {"sprem", fcn_desc(f_sprem, 3)},
        {"sqrfree", fcn_desc(f_sqrfree1, 1)},
        {"sqrfree", fcn_desc(f_sqrfree2, 2)},
        {"sqrt", fcn_desc(f_sqrt, 1)},
@@ -786,7 +810,7 @@ static char **fcn_completion(const char *text, int start, int end)
 void greeting(void)
 {
     cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " V" << VERSION << ")" << endl;
-    cout << "  __,  _______  Copyright (C) 1999-2001 Johannes Gutenberg University Mainz,\n"
+    cout << "  __,  _______  Copyright (C) 1999-2002 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;