2013-05-11 16:13:46 -04:00
|
|
|
#include "NodeTree.h"
|
2013-05-20 19:34:15 -04:00
|
|
|
#include "Parser.h"
|
2013-05-11 16:13:46 -04:00
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
|
|
|
|
|
|
std::ifstream inFile;
|
|
|
|
|
std::ofstream outFile;
|
|
|
|
|
|
|
|
|
|
inFile.open(argv[1]);
|
|
|
|
|
if (!inFile.is_open()) {
|
|
|
|
|
std::cout << "Problem opening input file " << argv[1] << "\n";
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
outFile.open(argv[2]);
|
|
|
|
|
if (!outFile.is_open()) {
|
|
|
|
|
std::cout << "Probelm opening output file " << argv[2] << "\n";
|
|
|
|
|
return(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NodeTree root;
|
|
|
|
|
root.setName("Root");
|
|
|
|
|
root.addChild(new NodeTree("SomeChild"));
|
|
|
|
|
root.addChild(new NodeTree("SomeOtherChild"));
|
|
|
|
|
root.get(0)->addChild(new NodeTree("Grandchildren"));
|
|
|
|
|
|
2013-05-20 19:34:15 -04:00
|
|
|
//outFile << root.DOTGraphString() << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Read the input file into a string
|
|
|
|
|
std::string inputFileString;
|
|
|
|
|
std::string line;
|
|
|
|
|
while(inFile.good()) {
|
|
|
|
|
getline(inFile, line);
|
|
|
|
|
inputFileString.append(line+"\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Parser parser;
|
|
|
|
|
parser.loadGrammer(inputFileString);
|
2013-05-24 13:24:33 -04:00
|
|
|
std::cout << "Creating State Set from Main" << std::endl;
|
2013-05-24 00:00:41 -04:00
|
|
|
parser.createStateSet();
|
2013-05-24 13:24:33 -04:00
|
|
|
std::cout << "finished State Set from Main" << std::endl;
|
|
|
|
|
std::cout << "Doing stateSetToString from Main" << std::endl;
|
2013-05-24 00:00:41 -04:00
|
|
|
std::cout << parser.stateSetToString() << std::endl;
|
2013-05-24 13:24:33 -04:00
|
|
|
std::cout << "finished stateSetToString from Main" << std::endl;
|
2013-05-20 22:59:57 -04:00
|
|
|
|
2013-05-20 19:34:15 -04:00
|
|
|
std::cout << inputFileString << std::endl;
|
2013-05-20 22:59:57 -04:00
|
|
|
std::cout << parser.grammerToString() << std::endl;
|
|
|
|
|
std::cout << parser.grammerToDOT() << std::endl;
|
2013-05-20 19:34:15 -04:00
|
|
|
|
2013-05-20 22:59:57 -04:00
|
|
|
outFile << parser.grammerToDOT() << std::endl;
|
2013-05-11 16:13:46 -04:00
|
|
|
|
|
|
|
|
inFile.close();
|
|
|
|
|
outFile.close();
|
|
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|