-
Notifications
You must be signed in to change notification settings - Fork 1
/
EricByName.java
94 lines (78 loc) · 2.19 KB
/
EricByName.java
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import Interpreter.*;
import viz.*;
import java.io.*;
public class EricByName
{
public static void main(String[] args)
{
System.out.println("Starting");
Global.InterpreterType = InterpreterTypes.BY_NAME;
BufferedReader br = null;
try
{
br = new BufferedReader(new FileReader(args[0]));
}
catch (Exception e)
{
System.out.println(e);
}
VizParser parser = new VizParser(br);
try
{
ASTProgram program = (ASTProgram)parser.program();
RandomizingVisitor2<ByNameVariable> rv = new RandomizingVisitor2<ByNameVariable>(ByNameVariable.class, true);
program.jjtAccept(rv, null);
System.out.println("Successfully Parsed");
System.out.println("________________\n");
program.buildCode();
String[] initial = {"1. The Arguments are copied into the function.", "2. The program is run (click next to continue)."};
XAALConnector xc = new XAALConnector(initial, "Call by Name", true);
String p0 = xc.addCodePage(program.getPseudocode());
Global.currentPage = p0;
// xc.showCodePage(p0);
xc.startSnap(1);
xc.startPar();
xc.showCodePage(p0);
xc.endPar();
xc.endSnap();
xc.startSnap(2);
xc.startPar();
xc.showCodePage(p0);
xc.endPar();
xc.startPar();
QuestionFactory questionFactory = new QuestionFactory();
ByNameVisitor0 bm = new ByNameVisitor0();
bm.setXAALConnector(xc);
program.jjtAccept(bm, null);
Global.lineNumber = 1;
program.codeBuilt = false;
program.buildCode();
String p2 = xc.addCodePage(program.getPseudocode());
xc.swapCodePage(p0, p2);
Global.executing = true;
xc.endPar();
xc.endSnap();
Global.lineNumber = 1;
program.codeBuilt = false;
program.buildCode();
xc.startSnap(1,program.getPseudocode());
xc.startPar();
xc.hideCodePage(p2);
xc.endPar();
for (String s : program.getPseudocode())
{
System.out.println(s);
}
ByNameInterpretVisitor iv = new ByNameInterpretVisitor();
iv.setXAALConnector(xc);
iv.setQuestionFactory(questionFactory);
program.jjtAccept(iv, null);
xc.draw(args[1]);
System.out.println("Visualization file created");
}
catch (Exception e)
{
System.out.println(e);
}
}
}