Example #1
0
int __etest(const char *program)
{
	FILE *f = fopen("/tmp/tmp", "w");
	if (f == NULL) {
		//fprintf(stderr, "open fail %s (%s)\n", strerror(errno), argv[1]);
		exit(-1);
	}
	fwrite(program, 1, strlen(program), f);
	fclose(f);

	SCParser parser;
	AST *ast = parser.parse("/tmp/tmp");

	assert(ast);

	DBG("%s", ast->toString().c_str());
	DBG("\n");
	DBG("%s", ast->toSource().c_str());

	TypeCheck typeCheck;
	ast->accept(&typeCheck);

	DBG("%s\n", SymbolTable.toString().c_str());

	int err = typeCheck.getLastError();
	return err;
}
Example #2
0
void testFile(const char *file)
{
	SCParser parser;

	AST *ast = parser.parse(file);
	if (ast) {
		DBG("%s", ast->toString().c_str());
		DBG("\n");
		DBG("%s", ast->toSource().c_str());
	}
	TypeCheck typeCheck;
	ast->accept(&typeCheck);
	//int err = typeCheck.getLastError();
}