Esempio n. 1
0
        private static ASTFunction ParseTopLevelExpression()
        {
            ASTExpression e = ParseExpression();

            if (e == null)
            {
                return(null);
            }

            // create an anonymous prototype to evaluate the expression
            ASTPrototype proto = new ASTPrototype("__proto", new List <string>());

            return(new ASTFunction(proto, e));
        }
Esempio n. 2
0
        private static ASTFunction ParseDefinition()
        {
            NextToken();                           // eat the 'def' keyword

            ASTPrototype proto = ParsePrototype(); // parse the definition

            if (proto == null)
            {
                return(null);
            }

            ASTExpression body = ParseExpression(); // and the body

            if (body != null)
            {
                return(new ASTFunction(proto, body));
            }

            return(null);
        }
Esempio n. 3
0
 public ASTFunction(ASTPrototype prototype, ASTExpression body)
 {
     Prototype = prototype;
     Body      = body;
 }