-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVariable Replacing.cs
45 lines (43 loc) · 1.34 KB
/
Variable Replacing.cs
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
using static PogCode_Interpreter.Globals;
namespace PogCode_Interpreter
{
class Variable_Replacing
{
Program p = new Program();
public string Replace(string line)
{
if (line.Contains('{') && line.Contains('}'))
{
if (line.IndexOf('{') > line.IndexOf('}'))
{
p.ExceptionHandler(7, LineN, Line);
}
else
{
do
{
string var = line.Remove(line.IndexOf('}'));
var = var.Substring(var.IndexOf('{') + 1);
if (AllVars.ContainsKey(var))
{
if (AllVars[var] == null)
{
p.ExceptionHandler(9, LineN, Line);
}
else
{
line = line.Replace($"{{{var}}}", AllVars[var][var]);
}
}
else
{
break;
}
}
while (line.Contains('{'));
}
}
return line;
}
}
}