public static plt_node eval_node(plt_node input) { plt_tail ret; do { if (input != null) { ret = input.eval(); } else { ret = plt_tail.nil; } if (ret.is_tail) { input = ret.value; } } while (ret.is_tail); return(ret.value); }
public override plt_tail eval() { return(exp.eval()); }
public static plt_node eval_node(plt_node input) { plt_tail ret; do { if (input != null){ ret = input.eval(); } else { ret = plt_tail.nil; } if (ret.is_tail) { input = ret.value; } } while (ret.is_tail); return ret.value; }
public override plt_tail eval() { if (_member.Count == 0) { return(plt_tail.nil); } plt_node afirst = plt_node.eval_node(_member[0]); if (afirst == null) { return(plt_tail.nil); } {//特殊的函数 //特殊情况-不解释参数 if (ReferenceEquals(afirst, plt_lambda.quote)) { if (_member.Count < 2) { return(plt_tail.nil); } return(new plt_tail(_member[1], false)); } if (ReferenceEquals(afirst, plt_lambda.make_lambda)) { plt_list_lambda ret = new plt_list_lambda(); ret.arg_name = _member[1] as plt_list; ret.exp = _member[2]; return(new plt_tail(ret, false)); } if (ReferenceEquals(afirst, plt_lambda.cond)) { for (int i = 1; i + 1 < _member.Count; i += 2) { plt_node _if = plt_node.eval_node(_member[i]); if (_if != null) { return(new plt_tail(_member[i + 1], true)); } } } //宏 不解释参数 plt_lambda lismacro = afirst as plt_lambda; if (lismacro != null && lismacro.ismacro) { lismacro.mix_env(this); return(lismacro.eval()); } } plt_list args_eval = new plt_list(); args_eval.add(afirst); for (int i = 1; i < _member.Count; i++) { args_eval.add(plt_node.eval_node(_member[i])); } plt_lambda func = afirst as plt_lambda; if (func != null) { func.mix_env(args_eval); } return(afirst.eval()); }