-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.cpp
More file actions
53 lines (45 loc) · 863 Bytes
/
Main.cpp
File metadata and controls
53 lines (45 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// LSystem.cpp : Defines the entry point for the console application.
//
#include <stdio.h>
#include <iostream>
#include "Parser.tab.h"
#include "LSystem.h"
using namespace std;
extern LSystem::AST::Grammar * mGrammar;
extern char * fileName;
extern FILE * yyin;
int yyparse ();
int main(int argc, char ** argv)
{
#if defined(YYDEBUG) && defined(DEBUG)
// yydebug = 1;
#endif
try
{
if (argc > 1)
{
if (NULL == (yyin = fopen(argv[1], "rt")))
{
cerr << "error: cannot open: " << argv[1] << endl;
exit(1);
}
fileName = argv[1];
}
//yydebug = 1;
yyparse();
if (mGrammar != NULL)
{
LSystem::LSystem lsys(mGrammar);
lsys.Run();
}
}
catch (const std::exception& x)
{
cerr << "ERROR: exception caught: " << x.what() << endl;
}
catch (...)
{
cerr << "ERROR: unknown exception caught" << endl;
}
return 0;
}