/
main.cc
57 lines (43 loc) · 905 Bytes
/
main.cc
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
53
54
55
56
#include "Graph.h"
#include "Environment.h"
#include "Frame.h"
#include "CallStack.h"
#include "Function.h"
#include "lex.yy.hh"
#include "AdjMatrix.h"
//#define DEBUG
#define YYDEBUG 1
extern int yydebug;
FILE *fid=0;
Environment &symboltable = *new Environment;
Frame *f=new Frame;
CallStack cs;
const char *protname;
AdjMatrix *adjmat;
int main(int ARGC, char *ARGV[])
{
Graph *res;
f->setEnv(symboltable);
yydebug=0;
if(ARGC<2){
fprintf(stderr, "No protocol to parse\n");
return 1;
}
fid=fopen(ARGV[1], "r");
protname = ARGV[1];
if(!fid){
fprintf(stderr, "Error opening protocol file: %s\n", ARGV[1]);
return 1;
}
f->setStream(fid);
cs.push(*f);
try { res=(Graph *)&(cs.Run()); }
catch(int)
{
return(1);
}
adjmat = &res->Visit();
//adjmat->toDot(res->GetNodes(), "out.dot");
//fprintf(stdout, "Protocol correctly parsed.\n");
return 0;
}