-ExprAST *Error(const char *Str) { fprintf(stderr, "Error: %s\n", Str);return 0;}
-PrototypeAST *ErrorP(const char *Str) { Error(Str); return 0; }
-FunctionAST *ErrorF(const char *Str) { Error(Str); return 0; }
+std::unique_ptr<ExprAST> Error(const char *Str) {
+ fprintf(stderr, "Error: %s\n", Str);
+ return nullptr;
+}
+std::unique_ptr<PrototypeAST> ErrorP(const char *Str) {
+ Error(Str);
+ return nullptr;
+}
+std::unique_ptr<FunctionAST> ErrorF(const char *Str) {
+ Error(Str);
+ return nullptr;
+}
+
+static std::unique_ptr<ExprAST> ParseExpression();
+
+/// numberexpr ::= number
+static std::unique_ptr<ExprAST> ParseNumberExpr() {
+ auto Result = llvm::make_unique<NumberExprAST>(NumVal);
+ getNextToken(); // consume the number
+ return std::move(Result);
+}
+
+/// parenexpr ::= '(' expression ')'
+static std::unique_ptr<ExprAST> ParseParenExpr() {
+ getNextToken(); // eat (.
+ auto V = ParseExpression();
+ if (!V)
+ return nullptr;