newly added. Not for productive used yetsvn diff | grep Index:

This commit is contained in:
nemu
2008-01-08 08:31:58 +00:00
commit c6cc508aaf
85 changed files with 14397 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
#include <iostream>
using namespace std;
#include "PFunctionHandler.h"
//-----------------------------------------------------
void syntax()
{
cout << endl << "spirit_fcn_test [--file <filename>] | [--help]";
cout << endl << " without arguments: interactive mode";
cout << endl << " --file <filename>: function block etc. from file";
cout << endl << " --help: this help";
cout << endl << endl;
}
//-----------------------------------------------------
void handle_input(vector<QString> &lines)
{
cout << endl << "will handle input ...";
cout << endl << "you should provide a PAR, a MAP, and a FUNCTION block";
cout << endl << " Map block:";
cout << endl << " MAP <map1> <map2> ... <mapM>";
cout << endl << " Parameter block:";
cout << endl << " PAR <par1> <par2> ... <parN>";
cout << endl << " Function Block:";
cout << endl << " FUNCTION";
cout << endl << " fun1 = <function1>";
cout << endl << " fun2 = <function2>";
cout << endl << " ...";
cout << endl << " funX = <functionX>";
cout << endl << " END";
cout << endl << "to get out of the input handle type '.q'";
cout << endl;
bool done = false;
char str[128];
do {
cout << ">> ";
cin.getline(str, sizeof(str));
if (!strcmp(str, ".q"))
done = true;
else
lines.push_back(str);
} while (!done);
}
//-----------------------------------------------------
int main(int argc, char *argv[])
{
bool inputFile = false;
if (argc > 3) {
syntax();
return 0;
} else if (argc == 2) {
syntax();
return 0;
} else if (argc == 3) {
if (strcmp(argv[1], "--file")) {
syntax();
return 0;
} else {
inputFile = true;
}
}
PFunctionHandler *fcnHandler = 0;
if (inputFile) {
fcnHandler = new PFunctionHandler(argv[2]);
} else {
vector<QString> lines;
handle_input(lines);
cout << endl << "lines.size() = " << lines.size();
fcnHandler = new PFunctionHandler(lines);
}
if (fcnHandler == 0) {
cout << endl << "Couldn't invoke function handler, sorry ..." << endl;
return 0;
}
bool go_on = fcnHandler->IsValid();
if (go_on) {
cout << endl << "will do the parsing ...";
if (fcnHandler->DoParse()) {
cout << endl << "will do the evaluation ...";
for (unsigned int i=0; i<fcnHandler->GetNoOfFuncs(); i++)
cout << endl << "FUN" << fcnHandler->GetFuncNo(i) << " = " << fcnHandler->Eval(fcnHandler->GetFuncNo(i));
}
}
// clean up
if (fcnHandler) {
delete fcnHandler;
fcnHandler = 0;
}
return 1;
}