本文整理汇总了C#中SymbolTable.Add方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable.Add方法的具体用法?C# SymbolTable.Add怎么用?C# SymbolTable.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable.Add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add_definition
public static EvalResult add_definition(SymbolTable symbols, FunCall val)
{
var new_fun_name = val.args[0].args.First().value.value;
var parameters = FunCall.id_list(val.args[0].flattened_args().Skip(1).ToList());
var fun_body = val.args[1];
symbols.Add(new_fun_name, FunCall.id_list(new List<FunCall> { parameters, fun_body }));
return new EvalResult(new EvalT(symbols, new FunCall(Token.symbol("Function Defined"))));
}
示例2: CiParser
public CiParser()
{
SymbolTable globals = new SymbolTable();
globals.Add(CiBoolType.Value);
globals.Add(CiByteType.Value);
globals.Add(CiIntType.Value);
globals.Add(CiStringPtrType.Value);
globals.Add(new CiConst { Name = "true", Value = true, Type = CiBoolType.Value });
globals.Add(new CiConst { Name = "false", Value = false, Type = CiBoolType.Value });
globals.Add(new CiConst { Name = "null", Value = null, Type = CiType.Null });
this.Symbols = new SymbolTable { Parent = globals };
}
示例3: Refactor
public static SymbolTable Refactor(this SymbolTable table, string function)
{
var st = new SymbolTable(null);
foreach (var item in table)
{
var parts = item.Key.Split('_');
if (int.Parse(parts[2]) == 0)
st.Add(SymbolTable.BuildSymbolId(function, parts[1],
int.Parse(parts[2])),
new Symbol
{
Function = function,
Name = parts[1],
Value = item.Value
});
}
return st;
}
示例4: evaluate_User_Function
public static EvalResult evaluate_User_Function(SymbolTable symbols, FunCall fun_call)
{
FunCall definition = symbols[fun_call.value.value];
FunCall funArgs = definition.args[0];
FunCall funBody = definition.args[1];
if (fun_call.args.Count != funArgs.args.Count)
return gen_function_call_error(fun_call, funArgs.args.Count);
var arg_pairs = funArgs.args.Zip(fun_call.args, (a, b) => new Tuple<FunCall, FunCall>(a, b));
// Bind args and add to symbol table
foreach (var arg_pair in arg_pairs) symbols.Add(arg_pair.Item1.value.value, arg_pair.Item2);
return evaluate_FunCall(symbols, funBody);
}
示例5: NullObjectsCannotBeAdded
public void NullObjectsCannotBeAdded()
{
SymbolTable table = new SymbolTable();
Assert.Throws<NullReferenceException>(() => table.Add(null));
}
示例6: StructDeclSymbol
/// <summary>
/// Initializes a struct declaration by passing a dictionary as the current members.
/// </summary>
/// <param name="theMembers">The dictionary with keyvaluepairs you know</param>
internal StructDeclSymbol(Dictionary<string, Symbol> theMembers)
: base()
{
members = new SymbolTable();
members.Add(theMembers);
}