1 | using System.Collections.Generic;
|
---|
2 | using System;
|
---|
3 |
|
---|
4 | public class SymbolBuilder {
|
---|
5 | private static HashSet<string> symbols;
|
---|
6 |
|
---|
7 | private static Dictionary<string, string> formalParameter;
|
---|
8 | private static Dictionary<string, string> init;
|
---|
9 | private static Dictionary<string, string> mutate;
|
---|
10 | private static Dictionary<string, string> code;
|
---|
11 |
|
---|
12 | public static void Initialize()
|
---|
13 | {
|
---|
14 | symbols = new HashSet<string>();
|
---|
15 | formalParameter = new Dictionary<string, string>();
|
---|
16 | init = new Dictionary<string, string>();
|
---|
17 | mutate = new Dictionary<string, string>();
|
---|
18 | code = new Dictionary<string, string>();
|
---|
19 | }
|
---|
20 |
|
---|
21 | public static void CreateSymbol(string ident, string formalParameterList) {
|
---|
22 | symbols.Add(ident);
|
---|
23 | formalParameter[ident] = formalParameterList;
|
---|
24 | init[ident] = "";
|
---|
25 | mutate[ident] = "";
|
---|
26 | code[ident] = "";
|
---|
27 | }
|
---|
28 |
|
---|
29 | public static void DefineInitialization(string ident, string code) {
|
---|
30 | init[ident] = code;
|
---|
31 | }
|
---|
32 |
|
---|
33 | public static void DefineMutation(string ident, string code) {
|
---|
34 | mutate[ident] = code;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public static void AddCode(string ident, string c) {
|
---|
38 | code[ident] = c;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public static void WriteSymbols() {
|
---|
42 | foreach(var s in symbols) {
|
---|
43 | Console.WriteLine(s);
|
---|
44 | Console.WriteLine(init[s]);
|
---|
45 | Console.WriteLine(mutate[s]);
|
---|
46 | Console.WriteLine(code[s]);
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|