]> www.ginac.de Git - ginac.git/commitdiff
Added keywords "complex_symbols" and "real_symbols" to influence symbol production.
authorJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Sun, 4 Jan 2004 16:13:56 +0000 (16:13 +0000)
committerJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Sun, 4 Jan 2004 16:13:56 +0000 (16:13 +0000)
ginsh/ginsh.h
ginsh/ginsh_lexer.ll
ginsh/ginsh_parser.yy

index bcdfe9ae4666f569a12d281b19d2d0ead9a2648e..a7ec33dcdb49fe37483ddbeaf646a6161f92ba03 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  Global definitions for ginsh.
  *
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 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
@@ -73,4 +73,7 @@ extern char **file_list;
 typedef map<string, symbol> sym_tab;
 extern sym_tab syms;
 
+// Type of symbols to generate (real or complex)
+extern unsigned symboltype;
+
 #endif
index 4194f94337af97e8ecfa155cee9c34a3c892ac61..896c28d34a3ae38eb91fce11cd2b95eb619dfda9 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with flex. */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 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
@@ -37,6 +37,9 @@
 // Table of all used symbols
 sym_tab syms;
 
+// Type of symbols to generate (real or complex)
+unsigned symboltype = symbol_options::complex;
+
 // lex input function
 static int ginsh_input(char *buf, int max_size);
 %}
@@ -79,6 +82,8 @@ xyzzy                 return T_XYZZY;
 inventory              return T_INVENTORY;
 look                   return T_LOOK;
 score                  return T_SCORE;
+complex_symbols return T_COMPLEX_SYMBOLS;
+real_symbols    return T_REAL_SYMBOLS;
 
                        /* comparison */
 "=="                   return T_EQUAL;
@@ -105,7 +110,11 @@ score                      return T_SCORE;
 {A}{AN}*               {
                                sym_tab::const_iterator i = syms.find(yytext);
                                if (i == syms.end()) {
-                                       yylval = syms[yytext] = *(new symbol(yytext));
+                                       if (symboltype == symbol_options::complex) {
+                                               yylval = syms[yytext] = *(new symbol(yytext));
+                                       } else {
+                                               yylval = syms[yytext] = *(new symbol(yytext, symbol_options::real));
+                                       }
                                } else
                                        yylval = i->second;
                                return T_SYMBOL;
index a7a38efe179fc584cd67eec16ea9cce279997ec3..00aaea3e277eca841256471db8ae153835a5386f 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with yacc/bison. */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 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
@@ -93,7 +93,7 @@ static void print_help_topics(void);
 %token T_EQUAL T_NOTEQ T_LESSEQ T_GREATEREQ
 
 %token T_QUIT T_WARRANTY T_PRINT T_IPRINT T_PRINTLATEX T_PRINTCSRC T_TIME
-%token T_XYZZY T_INVENTORY T_LOOK T_SCORE
+%token T_XYZZY T_INVENTORY T_LOOK T_SCORE T_COMPLEX_SYMBOLS T_REAL_SYMBOLS
 
 /* Operator precedence and associativity */
 %right '='
@@ -202,6 +202,8 @@ line        : ';'
                cout << (syms.size() > 350 ? 350 : syms.size());
                cout << " out of a possible 350.\n";
        }
+       | T_REAL_SYMBOLS { symboltype = symbol_options::real; }
+       | T_COMPLEX_SYMBOLS { symboltype = symbol_options::complex; }
        | 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) +
@@ -817,7 +819,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-2003 Johannes Gutenberg University Mainz,\n"
+    cout << "  __,  _______  Copyright (C) 1999-2004 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;