示例#1
0
        public CatExpr NodesToFxns(string name, List <CatAstNode> nodes)
        {
            CatExpr result = new CatExpr();

            for (int i = 0; i < nodes.Count; ++i)
            {
                CatAstNode node = nodes[i];
                if (node.GetLabel().Equals(AstLabel.Name))
                {
                    string s = node.ToString();
                    if (s.Equals(name))
                    {
                        result.Add(new SelfFunction(name));
                    }
                    else
                    {
                        result.Add(ThrowingLookup(s));
                    }
                }
                else if (node is AstLiteral)
                {
                    result.Add(LiteralToFunction(name, node as AstLiteral));
                }
                else if (node is AstDef)
                {
                    MakeFunction(node as AstDef);
                }
                else if (node is AstMacro)
                {
                    MetaCat.AddMacro(node as AstMacro);
                }
                else
                {
                    throw new Exception("unable to convert node to function: " + node.ToString());
                }
            }
            return(result);
        }
示例#2
0
文件: CatLambda.cs 项目: noprompt/cat
 public static bool TermEquals(CatAstNode term, string var)
 {
     return(term.ToString().Equals(var));
 }
示例#3
0
 public static bool TermEquals(CatAstNode term, string var)
 {
     return term.ToString().Equals(var);
 }