本文整理汇总了C#中SymbolTable.ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C# SymbolTable.ContainsKey方法的具体用法?C# SymbolTable.ContainsKey怎么用?C# SymbolTable.ContainsKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymbolTable
的用法示例。
在下文中一共展示了SymbolTable.ContainsKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: evaluate_Identity
public static EvalResult evaluate_Identity(SymbolTable symbols, FunCall val)
{
// Evaluate symbol
if (val.value != null && val.value.type == Lexical.Symbol && symbols.ContainsKey(val.value.value))
{
return evaluate_Identity(symbols, symbols[val.value.value]);
}
else return new EvalResult(new EvalT(symbols, val));
}
示例2: ResolveView
public string ResolveView(Route route, SymbolTable model)
{
var viewKey = string.Format("{0}_visao_0", route.Action);
return model.ContainsKey(viewKey) ? model[viewKey].ToString(): route.Action;
}
示例3: evaluate_Function
public static EvalResult evaluate_Function(SymbolTable symbols, FunCall fun_call)
{
var fun_name = fun_call.value.value;
if (reserved_symbols.Contains(fun_name)) return evaluate_System_Function(symbols, fun_call);
else if (symbols.ContainsKey(fun_name)) return evaluate_User_Function(symbols, fun_call);
return null;
}
示例4: math_op
public static EvalResult math_op(SymbolTable symbols, FunCall fun, Func<Token, double, double> math_op, string func_name)
{
var args = fun.args.Select(a => evaluate_FunCall(symbols, a));
Func<FunCall, bool> isNumerical = arg => arg.value.type == Lexical.Int || arg.value.type == Lexical.Float;
double sum = 0;
bool seen_first_val = false;
foreach (var arg in fun.args)
{
FunCall val = arg;
if (!isNumerical(val) && symbols.ContainsKey(arg.value.value))
val = symbols[arg.value.value];
if (isNumerical(val))
{
if (!seen_first_val)
{
sum = math_identity(val.value);
seen_first_val = true;
}
else sum = math_op(val.value, sum);
}
else
{
string prefix = (val.value.type == Lexical.Symbol) ? "Undefined Symbol" : "Non-numerical value ";
string message = prefix + val.ToString() + " given to " + func_name;
var error = new Error(fun.value.line_num, val.ToString(), message);
return new EvalResult(error);
}
}
var isInt = Regex.IsMatch(sum.ToString(), @".*\.0+");
Token result = isInt ? new Token(Lexical.Int, 0, ((int)sum).ToString()) : new Token(Lexical.Float, 0, sum.ToString());
return new EvalResult(new EvalT(symbols, new FunCall(result)));
}