-/*
- * ginsh.y - GiNaC Interactive Shell, input grammar definition
+/** @file ginsh_parser.yy
+ *
+ * Input grammar definition for ginsh.
+ * This file must be processed with yacc/bison.
+ *
+ * GiNaC Copyright (C) 1999 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * This file must be processed with yacc/bison
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <unistd.h>
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern "C" {
-#include <readline/readline.h>
-#include <readline/history.h>
-}
-
#include <map>
#include <string>
#include <stdexcept>
-#include <ginac/ginac.h>
#include "ginsh.h"
// Original readline settings
YYERROR;
}
}
+ | exp ':'
+ {
+ try {
+ push($1);
+ } catch (exception &e) {
+ cerr << e.what() << endl;
+ YYERROR;
+ }
+ }
| T_PRINT '(' exp ')' ';'
{
try {
cout << " out of a possible 350.\n";
}
| error ';' {yyclearin; yyerrok;}
+ | error ':' {yyclearin; yyerrok;}
;
exp : T_NUMBER {$$ = $1;}
*/
%%
-const int GINSH_VERSION = 0;
-const int GINSH_REVISION = 3;
-
// Error print routine
int yyerror(char *s)
{
return function(serial, es).eval(1);
}
-void ginsh_get_ginac_functions(void)
+void GiNaC::ginsh_get_ginac_functions(void)
{
vector<registered_function_info>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
unsigned serial = 0;
{
// Print banner in interactive mode
if (isatty(0)) {
- cout << "ginsh - GiNaC Interactive Shell V" << GINSH_VERSION << "." << GINSH_REVISION << endl;
+ 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";
orig_completion_append_character = rl_completion_append_character;
orig_basic_word_break_characters = rl_basic_word_break_characters;
+ // Init input file list, open first file
+ num_files = argc - 1;
+ file_list = argv + 1;
+ if (num_files) {
+ yyin = fopen(*file_list, "r");
+ if (yyin == NULL) {
+ cerr << "Can't open " << *file_list << endl;
+ exit(1);
+ }
+ num_files--;
+ file_list++;
+ }
+
// Parse input, catch all remaining exceptions
int result;
again: try {