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)); }
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); }
public ASTFunction(ASTPrototype prototype, ASTExpression body) { Prototype = prototype; Body = body; }