All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javacc-7.0.4.examples.JJTreeExamples.cpp.eg1.cc Maven / Gradle / Ivy

The newest version!
#include 
#include 
#include 
#include 
#include 
#include "JavaCC.h"
#include "Parser.h"
#include "ParseException.h"
#include "ParserTokenManager.h"

using namespace std;
using namespace EG1;

JAVACC_STRING_TYPE ReadFileFully(char *file_name) {
	return "(1 + 2) * (a + b);\n";
}

int main(int argc, char** argv) {
	cout << "Reading from standard input..." << endl;
	JAVACC_STRING_TYPE s = ReadFileFully(argv[1]);
	try {
		CharStream *stream = new CharStream(s.c_str(), s.size() - 1, 1, 1);
		ParserTokenManager *scanner = new ParserTokenManager(stream);
		Parser parser(scanner);
		SimpleNode* n = parser.Start();
		n->dump("");
		cout << "Thank you." << endl;
	} catch (const ParseException& e) {

	}
	return 0;
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy