-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScope.java
42 lines (37 loc) · 939 Bytes
/
Scope.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
import java.util.*;
public class Scope extends Statement
{
public List<Statement> Inside;
public Scope()
{
Inside = new ArrayList<Statement>();
}
public @Override void EvalStmt(Cpu c)
{
var env = new Environement(c.Env);
c.Env = env;
for(var s : Inside)
{
c.Execute(s);
}
c.Env = c.Env.Parent;
}
public @Override String toStringStmt()
{
StringBuilder sb = new StringBuilder();
sb.append(ColoredToken("{"));
sb.append("\n");
for(var stmt : Inside)
{
for(var s : stmt.toString().split("\n"))
{
sb.append(" ");
sb.append(s.toString());
sb.append("\n");
}
}
sb.append(ColoredToken("}"));
var str = sb.toString();
return str;
}
}