/// toplevelexpr ::= expression private FunctionAST ParseTopLevelExpr() { ExprAST e = this.ParseExpression(); if (e == null) { return(null); } // Make an anonymous proto. PrototypeAST proto = new PrototypeAST(string.Empty, new List <string>()); return(new FunctionAST(proto, e)); }
// definition ::= 'def' prototype expression private FunctionAST ParseDefinition() { this.scanner.GetNextToken(); // eat def. PrototypeAST proto = this.ParsePrototype(); if (proto == null) { return(null); } ExprAST body = this.ParseExpression(); if (body == null) { return(null); } return(new FunctionAST(proto, body)); }
public FunctionAST(PrototypeAST protptype, ExprAST body) { Protptype = protptype ?? throw new ArgumentNullException(nameof(protptype)); Body = body ?? throw new ArgumentNullException(nameof(body)); }