From c030e24444ef604e7343bda6e88b79bbfbfe6138 Mon Sep 17 00:00:00 2001 From: Jens Vollinga Date: Sun, 4 Jan 2004 16:13:56 +0000 Subject: [PATCH] Added keywords "complex_symbols" and "real_symbols" to influence symbol production. --- ginsh/ginsh.h | 5 ++++- ginsh/ginsh_lexer.ll | 13 +++++++++++-- ginsh/ginsh_parser.yy | 8 +++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ginsh/ginsh.h b/ginsh/ginsh.h index bcdfe9ae..a7ec33dc 100644 --- a/ginsh/ginsh.h +++ b/ginsh/ginsh.h @@ -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 sym_tab; extern sym_tab syms; +// Type of symbols to generate (real or complex) +extern unsigned symboltype; + #endif diff --git a/ginsh/ginsh_lexer.ll b/ginsh/ginsh_lexer.ll index 4194f943..896c28d3 100644 --- a/ginsh/ginsh_lexer.ll +++ b/ginsh/ginsh_lexer.ll @@ -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; diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index a7a38efe..00aaea3e 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -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; -- 2.44.0