-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterpreterClient.java
More file actions
49 lines (38 loc) · 1.2 KB
/
InterpreterClient.java
File metadata and controls
49 lines (38 loc) · 1.2 KB
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
public class InterpreterClient {
private InterpreterEngine interpreterEngine;
public InterpreterClient(InterpreterEngine interpreterEngine) {
this.interpreterEngine = interpreterEngine;
}
public String interpret(String inputData,Process p) {
Expression expression = null;
if (inputData.contains("printFromTo")) {
expression = new printFromToExpression(inputData, p);
}
else if (inputData.contains("print")) {
expression = new PrintExpression(inputData, p);
}
else if(inputData.contains("input")){
expression = new InputExpression(inputData, p);
}
else if(inputData.contains("readFile")){
expression = new readFileExpression(inputData, p);
}
else if(inputData.contains("assign")){
expression = new AssignExpression(inputData, p);
}
else if(inputData.contains("writeFile")){
expression = new writeFileExpression(inputData, p);
}
else {
throw new RuntimeException(inputData + " is not valid expression!!");
}
String result = null;
try {
result = expression.interpret(interpreterEngine, p);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}