]> www.ginac.de Git - ginac.git/blobdiff - ginsh/ginsh_parser.yy
- Import namespace std globally.
[ginac.git] / ginsh / ginsh_parser.yy
index 52a134f599fb0a9e8fee39ab8bc482f3bfba505d..d792a242f9c498a788fbf1e9ecf5523945e4a6e5 100644 (file)
@@ -145,13 +145,14 @@ line      : ';'
                        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_TIME            {print_help("time");}
        | '?' '?'               {print_help_topics();}
        | T_QUIT                {YYACCEPT;}
        | T_WARRANTY {
@@ -175,6 +176,13 @@ line       : ';'
                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;}
        ;
@@ -187,13 +195,6 @@ exp        : T_NUMBER              {$$ = $1;}
        | 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) {