#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <istream>
#include <ostream>
#include <vector>

#include "Header.hh"
#include "FuncParser.hh"

int main(int argc, char *argv[]) {

    vector<string> exprList = *(new vector<string>());
    exprList.push_back(string(""));
    exprList.push_back(string("g"));
    exprList.push_back(string("      g"));
    exprList.push_back(string("g      "));
    exprList.push_back(string("   g   "));
    exprList.push_back(string("g+g"));
    exprList.push_back(string("    g+g"));
    exprList.push_back(string("g    +g"));
    exprList.push_back(string("g+    g"));
    exprList.push_back(string("g+g    "));

    exprList.push_back(string("g l al pv1 pv2 tri trp    "));
    exprList.push_back(string("g+l+al+pv1+pv2+tri+trp    "));

    vector<string> funcList = *(new vector<string>());
    funcList.push_back(string("g"));
    funcList.push_back(string("g"));
    funcList.push_back(string("l"));
    funcList.push_back(string("al"));

    for (std::vector<string>::iterator i=exprList.begin(); i != exprList.end(); ++i) {
        std::cout << "expr=" << *i << endl;
        FuncParser funcParser(*i);
        //vector<FuncData> funcDataList = funcParser.parse();
        vector<FuncBase*> funcList = funcParser.parse();
        UInt4 ct=0;
        fprintf(stdout, "%3s %4s %s\n", "No.", "sym", "name");
        //for (std::vector<FuncData>::iterator i=funcDataList.begin(); i != funcDataList.end(); ++i) {
        for (std::vector<FuncBase*>::iterator i=funcList.begin(); i != funcList.end(); ++i) {
            fprintf(stdout, "%3u %4s %s\n", ct, (*i)->getSymbol().c_str(), (*i)->getName().c_str());
            ++ct;
        }
        funcList.clear();
    }

    /*
    FuncParser parser = *(new FuncParser(funcList));
    vector<FuncBase*> fl = parser.parse();
    fprintf(stdout, "%3s %4s %s\n", "No.", "sym", "name");
    UInt4 ct=0;
    for (std::vector<FuncBase*>::iterator i=fl.begin(); i != fl.end(); ++i) {
        fprintf(stdout, "%3u %4s %s\n", ct, (*i)->getSymbol().c_str(), (*i)->getName().c_str());
        ++ct;
    }
    fl.clear();
    */
    

    return EXIT_SUCCESS;
}
