From 6a9911249d7121c57ba279c77a2e5c4b24212354 Mon Sep 17 00:00:00 2001 From: Alexander Frink Date: Tue, 14 Dec 1999 21:23:29 +0000 Subject: [PATCH] first release of GiNaCcint --- cint/configure | 40 +++++++ cint/dummy_ginsh.cpp | 14 +++ cint/ginaccint.cpp | 242 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 296 insertions(+) create mode 100755 cint/configure create mode 100644 cint/dummy_ginsh.cpp create mode 100644 cint/ginaccint.cpp diff --git a/cint/configure b/cint/configure new file mode 100755 index 00000000..0b3941f0 --- /dev/null +++ b/cint/configure @@ -0,0 +1,40 @@ +#!/bin/sh + +echo +echo "GiNaCcint configure script" +echo "--------------------------" +echo +echo "Warning: this is not a sophisticated GNU configure script!" +echo +echo "It tests if cint is installed" +echo "What it does NOT check:" +echo " the ginac source files (e.g. ginac.h) must be in ../ginac" +echo " libginac must have been compiled with -D NO_GINAC_NAMESPACE" +echo " libginac.a or libginac.so must be found in ../ginac/.libs" +echo " libcln.a or libcln.so must be in the standard link path" +echo + +if [ X"$CINTSYSDIR"X = "XX" ]; then + echo "ERROR: cint does not seem to be installed (\$CINTSYSDIR not set)" + exit +fi; +echo "ok, cint seems to be installed (\$CINTSYSDIR = $CINTSYSDIR)" + +if [ X`which cint`X = "XX" ]; then + echo "ERROR: cint not in \$PATH" + exit +fi; +echo "ok, cint seems to be in \$PATH" + +makecint -mk Makefile -o ginaccint -m \ + -D OBSCURE_CINT_HACK -D NO_GINAC_NAMESPACE \ + -I .. -I $CINTSYSDIR \ + -m -H ../ginac/ginac.h -C++ dummy_ginsh.cpp -C++ ginaccint.cpp \ + -l ../ginac/.libs/libginac.a -lcln \ + -cint -M0x10 +echo "ok, makecint has created the Makefile" + +echo +echo "Configuration done. Now type \"make\"." +echo "(please ignore template warnings about 'statement with no effect')" + diff --git a/cint/dummy_ginsh.cpp b/cint/dummy_ginsh.cpp new file mode 100644 index 00000000..0e384f2e --- /dev/null +++ b/cint/dummy_ginsh.cpp @@ -0,0 +1,14 @@ +#include + +#ifndef NO_GINAC_NAMESPACE +using namespace GiNaC; +#endif // ndef NO_GINAC_NAMESPACE + +void ginsh_get_ginac_functions(void) +{ +} + +ex IEvalf(void) +{ + return 0; +} diff --git a/cint/ginaccint.cpp b/cint/ginaccint.cpp new file mode 100644 index 00000000..27c643f7 --- /dev/null +++ b/cint/ginaccint.cpp @@ -0,0 +1,242 @@ +#include "G__ci.h" /* G__atpause is defined in G__ci.h */ +#include +#include +#include +#include +#include +#include +#include + +extern "C" G__value G__exec_tempfile G__P((char *file)); +extern "C" void G__store_undo_position(void); + +#ifdef OBSCURE_CINT_HACK + +#include + +template +string ToString(T const & t) +{ + char buf[256]; + ostrstream(buf,sizeof(buf)) << t << ends; + return buf; +} + +basic * ex::last_created_or_assigned_bp=0; +bool ex::last_created_or_assigned_bp_modified=false; + +#endif // def OBSCURE_CINT_HACK + +typedef list cplist; + +cplist filenames; + +void cleanup(void) +{ + for (cplist::iterator it=filenames.begin(); it!=filenames.end(); ++it) { + cout << "removing file " << *it << endl; + remove(*it); + free(*it); + } +} + +void sigterm_handler(int n) +{ + exit(1); +} + +bool is_whitespace_char(char c) +{ + return ((c==' ')||(c=='\t')||(c=='\n')||(c=='\r')); +} + +char first_non_whitespace_char(char const * s) +{ + int l=strlen(s); + int pos=0; + while ((pos=0)&&is_whitespace_char(s[pos])) pos--; + return s[pos]; +} + +string strip_whitespace(string const & s) +{ + string s2; + int l=s.length(); + for (int pos=0; pos\n"); + exec_tempfile("ex LAST,LLAST,LLLAST;\n"); + + bool quit=false; + bool next_command_is_function=false; + while (!quit) { + strcpy(prompt,"GiNaCcint> "); + int open_braces=0; + bool end_of_command=false; + string command; + while (!end_of_command) { + line=G__input(prompt); + + int pos = 0; + bool double_quote=false; + bool single_quote=false; + while(line[pos]!='\0') { + switch(line[pos]) { + case '"': + if (!single_quote) double_quote = !double_quote; + break; + case '\'': + if (!double_quote) single_quote = !single_quote; + break; + case '{': + if ((!single_quote)&&(!double_quote)) open_braces++; + break; + case '}': + if ((!single_quote)&&(!double_quote)) open_braces--; + break; + } + pos++; + } + command += line; + command += '\n'; + if (open_braces==0) { + if ((first_non_whitespace_char(command.c_str())=='#')|| + (first_non_whitespace_char(command.c_str())=='.')|| + (last_non_whitespace_char(command.c_str())==';')|| + (last_non_whitespace_char(command.c_str())=='}')) { + end_of_command=true; + } + } + strcpy(prompt," (more) > "); + } + string stripped_command=strip_whitespace(command); + if ((stripped_command=="quit;")|| + (stripped_command=="exit;")|| + (stripped_command=="bye;")|| + (stripped_command==".q")|| + (stripped_command==".quit")|| + (stripped_command==".exit")|| + (stripped_command==".bye")) { + quit=true; + } else if (stripped_command==".function") { + cout << "next expression can be a function definition" << endl; + next_command_is_function=true; + } else if (stripped_command==".cint") { + cout << endl << "switching to cint interactive mode" << endl; + cout << "'h' for help, 'q' to quit, '{ statements }' or 'p [expression]' to evaluate" << endl; + G__pause(); + cout << "back from cint" << endl; + } else if (command[0]=='.') { + cout << "special command (TBD): " << command << endl; + } else { + // cout << "now processing: " << command << endl; + if (next_command_is_function) { + next_command_is_function=false; + filenames.push_back(process_permanentfile(command)); + } else { + process_tempfile(command); + } + } + } + + return 0; +} + + + + + + + -- 2.44.0