* This file must be processed with yacc/bison. */
/*
- * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2001 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
try {
push($1);
} catch (exception &e) {
- cerr << e.what() << endl;
+ std::cerr << e.what() << endl;
YYERROR;
}
}
| T_PRINT '(' exp ')' ';' {
try {
- $3.printtree(cout);
+ $3.print(print_tree(std::cout));
} catch (exception &e) {
- cerr << e.what() << endl;
+ std::cerr << e.what() << endl;
YYERROR;
}
}
long i = ex_to_numeric(e).to_long();
cout << i << endl;
cout << "#o" << oct << i << endl;
- cout << "#x" << hex << i << endl;
+ cout << "#x" << hex << i << dec << endl;
} catch (exception &e) {
cerr << e.what() << endl;
YYERROR;
}
}
- | '?' T_SYMBOL {print_help(ex_to_symbol($2).getname());}
+ | '?' T_SYMBOL {print_help(ex_to_symbol($2).get_name());}
+ | '?' T_TIME {print_help("time");}
| '?' '?' {print_help_topics();}
| T_QUIT {YYACCEPT;}
| T_WARRANTY {
cout << (syms.size() > 350 ? 350 : syms.size());
cout << " out of a possible 350.\n";
}
+ | T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' {
+ getrusage(RUSAGE_SELF, &end_time);
+ cout << (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 << 's' << endl;
+ }
| error ';' {yyclearin; yyerrok;}
| error ':' {yyclearin; yyerrok;}
;
| 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) {
| exp '-' exp {$$ = $1 - $3;}
| exp '*' exp {$$ = $1 * $3;}
| exp '/' exp {$$ = $1 / $3;}
- | exp '%' exp {$$ = $1 % $3;}
| '-' exp %prec NEG {$$ = -$2;}
| '+' exp %prec NEG {$$ = $2;}
| exp '^' exp {$$ = power($1, $3);}
| exp '!' {$$ = factorial($1);}
| '(' exp ')' {$$ = $2;}
| '[' list_or_empty ']' {$$ = $2;}
- | T_MATRIX_BEGIN matrix T_MATRIX_END {$$ = lst_to_matrix($2);}
+ | T_MATRIX_BEGIN matrix T_MATRIX_END {$$ = lst_to_matrix(ex_to_lst($2));}
;
exprseq : exp {$$ = exprseq($1);}
return e[0].series(e[1], ex_to_numeric(e[2]).to_int());
}
-static ex f_sqrfree(const exprseq &e)
+static ex f_sqrfree1(const exprseq &e)
+{
+ return sqrfree(e[0]);
+}
+
+static ex f_sqrfree2(const exprseq &e)
{
- CHECK_ARG(1, symbol, sqrfree);
- return sqrfree(e[0], ex_to_symbol(e[1]));
+ CHECK_ARG(1, lst, sqrfree);
+ return sqrfree(e[0], ex_to_lst(e[1]));
}
static ex f_subs3(const exprseq &e)
{"quo", fcn_desc(f_quo, 3)},
{"rem", fcn_desc(f_rem, 3)},
{"series", fcn_desc(f_series, 3)},
- {"sqrfree", fcn_desc(f_sqrfree, 2)},
+ {"sqrfree", fcn_desc(f_sqrfree1, 1)},
+ {"sqrfree", fcn_desc(f_sqrfree2, 2)},
{"sqrt", fcn_desc(f_sqrt, 1)},
{"subs", fcn_desc(f_subs2, 2)},
{"subs", fcn_desc(f_subs3, 3)},
}
// All registered GiNaC functions
-#ifndef NO_NAMESPACE_GINAC
void GiNaC::ginsh_get_ginac_functions(void)
-#else // ndef NO_NAMESPACE_GINAC
-void ginsh_get_ginac_functions(void)
-#endif // ndef NO_NAMESPACE_GINAC
{
vector<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
unsigned serial = 0;
static fcn_tab::const_iterator find_function(const ex &sym, int req_params)
{
- const string &name = ex_to_symbol(sym).getname();
+ const string &name = ex_to_symbol(sym).get_name();
typedef fcn_tab::const_iterator I;
pair<I, I> b = fcns.equal_range(name);
if (b.first == b.second)
// For shell commands, revert back to filename completion
rl_completion_append_character = orig_completion_append_character;
rl_basic_word_break_characters = orig_basic_word_break_characters;
+ rl_completer_word_break_characters = rl_basic_word_break_characters;
return completion_matches(text, (CPFunction *)filename_completion_function);
} else {
// Otherwise, complete function names
rl_completion_append_character = '(';
rl_basic_word_break_characters = " \t\n\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~";
+ rl_completer_word_break_characters = rl_basic_word_break_characters;
return completion_matches(text, (CPFunction *)fcn_generator);
}
}
void greeting(void)
{
cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " V" << VERSION << ")" << endl;
- cout << " __, _______ Copyright (C) 1999-2000 Johannes Gutenberg University Mainz,\n"
+ cout << " __, _______ Copyright (C) 1999-2001 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;