Ejemplo n.º 1
0
        public AstLambda(PegAstNode node)
            : base(node)
        {
            CheckLabel(AstLabel.Lambda);
            CheckChildCount(node, 2);

            AstParam name = new AstParam(node.GetChild(0));

            mIdentifiers.Add(name.ToString());
            CatAstNode tmp = Create(node.GetChild(1));

            // lambda nodes either contain quotes or other lambda nodes
            if (!(tmp is AstQuote))
            {
                if (!(tmp is AstLambda))
                {
                    throw new Exception("expected lambda expression or quotation");
                }
                AstLambda lambda = tmp as AstLambda;
                mIdentifiers.AddRange(lambda.mIdentifiers);

                // Take ownership of the terms from the child lambda expression
                mTerms = lambda.mTerms;
            }
            else
            {
                AstQuote q = tmp as AstQuote;

                // Take ownership of the terms from the quote
                mTerms = q.mTerms;
            }
        }
Ejemplo n.º 2
0
        public AstLambda(PegAstNode node)
            : base(node)
        {
            CheckLabel(AstLabel.Lambda);
            CheckChildCount(node, 2);

            AstParam name = new AstParam(node.GetChild(0));
            mIdentifiers.Add(name.ToString());
            CatAstNode tmp = Create(node.GetChild(1));

            // lambda nodes either contain quotes or other lambda nodes
            if (!(tmp is AstQuote))
            {
                if (!(tmp is AstLambda))
                    throw new Exception("expected lambda expression or quotation");
                AstLambda lambda = tmp as AstLambda;
                mIdentifiers.AddRange(lambda.mIdentifiers);

                // Take ownership of the terms from the child lambda expression
                mTerms = lambda.mTerms;
            }
            else
            {
                AstQuote q = tmp as AstQuote;

                // Take ownership of the terms from the quote
                mTerms = q.mTerms;
            }
        }