]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.yy
- added using namespace GiNaC; after each #include<ginac/ginac.h>;
[ginac.git] / ginsh / ginsh_parser.yy
index 67d836060c3fdd93988570df40001def805e090b..99478df7ecbc44a67ee2095b03b3ee1066a5cf5a 100644 (file)
 #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
@@ -126,6 +116,15 @@ line       : ';'
                                YYERROR;
                        }
                }
+       | exp ':'
+               {
+                       try {
+                               push($1);
+                       } catch (exception &e) {
+                               cerr << e.what() << endl;
+                               YYERROR;
+                       }
+               }
        | T_PRINT '(' exp ')' ';'
                {
                        try {
@@ -146,6 +145,7 @@ line        : ';'
                        cout << " out of a possible 350.\n";
                }
        | error ';'             {yyclearin; yyerrok;}
+       | error ':'             {yyclearin; yyerrok;}
        ;
 
 exp    : T_NUMBER              {$$ = $1;}
@@ -487,7 +487,7 @@ static ex f_ginac_function(const exprseq &es, int serial)
        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;
@@ -658,6 +658,19 @@ int main(int argc, char **argv)
        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 {