-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionTable.cs
executable file
·51 lines (44 loc) · 1.75 KB
/
FunctionTable.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
46
47
48
49
50
51
/*=======================================================================
Wyvern compiler: Version 0.4
Copyright (C) 2019 Carlos Rivero A01371368, ITESM CEM
========================================================================*/
using System;
using System.Text;
using System.Collections.Generic;
namespace Wyvern {
public class FunctionTable: IEnumerable<KeyValuePair<string, int>> {
IDictionary<string, int> data = new SortedDictionary<string, int>();
//-----------------------------------------------------------
public override string ToString() {
var sb = new StringBuilder();
sb.Append("Function Table\n");
sb.Append("====================\n");
foreach (var entry in data) {
sb.Append(String.Format("{0}: {1}\n", entry.Key, entry.Value));
}
sb.Append("====================\n");
return sb.ToString();
}
//-----------------------------------------------------------
public int this[string key] {
get {
return data[key];
}
set {
data[key] = value;
}
}
//-----------------------------------------------------------
public bool Contains(string key) {
return data.ContainsKey(key);
}
//-----------------------------------------------------------
public IEnumerator<KeyValuePair<string, int>> GetEnumerator() {
return data.GetEnumerator();
}
//-----------------------------------------------------------
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
throw new NotImplementedException();
}
}
}