Exemplo n.º 1
0
        /// 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));
        }
Exemplo n.º 2
0
        // 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));
        }
Exemplo n.º 3
0
 public FunctionAST(PrototypeAST protptype, ExprAST body)
 {
     Protptype = protptype ?? throw new ArgumentNullException(nameof(protptype));
     Body      = body ?? throw new ArgumentNullException(nameof(body));
 }