本文整理汇总了C#中SymbolTable.WriteTable方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable.WriteTable方法的具体用法?C# SymbolTable.WriteTable怎么用?C# SymbolTable.WriteTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable.WriteTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert_Lookup_WriteTable_SymbolTableTest
public void Insert_Lookup_WriteTable_SymbolTableTest()
{
var count = 0;
var symTable = new SymbolTable();
symTable.Printer = (val) => { count++; };
symTable.Insert(Token.CreateToken("x", 0), 0);
symTable.Insert(Token.CreateToken("y", 0), 0);
symTable.Insert(Token.CreateToken("z", 0), 0);
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.Insert(Token.CreateToken("a", 0), 1);
symTable.Insert(Token.CreateToken("x", 0), 1);
symTable.Insert(Token.CreateToken("y", 0), 1);
symTable.Insert(Token.CreateToken("z", 0), 1);
symTable.Lookup("a").Content = CreateVariableContent();
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.WriteTable(0);
Assert.AreEqual(3, count);
count = 0;
symTable.WriteTable(1);
Assert.AreEqual(4, count);
count = 0;
symTable.WriteTable(2);
Assert.AreEqual(0, count);
}
示例2: CRUD_SymbolTableTest
public void CRUD_SymbolTableTest()
{
var count = 0;
var symTable = new SymbolTable();
symTable.Printer = (val) => { count++; };
symTable.Insert(Token.CreateToken("a", 0), 0);
symTable.Insert(Token.CreateToken("b", 0), 0);
symTable.Lookup("a").Content = CreateVariableContent();
symTable.Lookup("b").Content = CreateVariableContent();
symTable.Insert(Token.CreateToken("x", 0), 1);
symTable.Insert(Token.CreateToken("y", 0), 1);
symTable.Insert(Token.CreateToken("z", 0), 1);
symTable.Lookup("x").Content = CreateVariableContent();
symTable.Lookup("y").Content = CreateVariableContent();
symTable.Lookup("z").Content = CreateVariableContent();
symTable.Insert(Token.CreateToken("j", 0), 2);
symTable.Lookup("j").Content = CreateVariableContent();
// Delete depth 9, this should do nothing
symTable.DeleteDepth(9);
symTable.WriteTable(0);
symTable.WriteTable(1);
symTable.WriteTable(2);
Assert.AreEqual(6, count);
// Delete depth 1, 3 items should be deleted
symTable.DeleteDepth(1);
count = 0;
symTable.WriteTable(0);
symTable.WriteTable(1);
symTable.WriteTable(2);
Assert.AreEqual(3, count);
// Delete depth 0, 2 items should be deleted
symTable.DeleteDepth(0);
count = 0;
symTable.WriteTable(0);
symTable.WriteTable(1);
symTable.WriteTable(2);
Assert.AreEqual(1, count);
// Try deleting depth 0 again. This should have no effect
symTable.DeleteDepth(0);
count = 0;
symTable.WriteTable(0);
symTable.WriteTable(1);
symTable.WriteTable(2);
Assert.AreEqual(1, count);
}