Parser.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef _PARSER_H
  2. #define _PARSER_H
  3. // Standard includes
  4. #include <map>
  5. // Local includes
  6. #include "Ast.h"
  7. using namespace ast;
  8. namespace parser{
  9. static int CurTok;
  10. static std::map<char, int> BinopPrecedence;
  11. int getNextToken();
  12. static int GetTokPrecedence();
  13. std::unique_ptr<ExprAST> Error(const char *Str);
  14. std::unique_ptr<PrototypeAST> ErrorP(const char *Str);
  15. static std::unique_ptr<ExprAST> ParseExpression();
  16. static std::unique_ptr<ExprAST> ParseNumberExpr();
  17. static std::unique_ptr<ExprAST> ParseParenExpr();
  18. static std::unique_ptr<ExprAST> ParseIdentifierExpr();
  19. static std::unique_ptr<ExprAST> ParseIfExpr();
  20. static std::unique_ptr<ExprAST> ParseForExpr();
  21. static std::unique_ptr<ExprAST> ParsePrimary();
  22. static std::unique_ptr<ExprAST> ParseUnary();
  23. static std::unique_ptr<ExprAST> ParseBinOpRHS(int ExprPrec,
  24. std::unique_ptr<ExprAST> LHS);
  25. static std::unique_ptr<PrototypeAST> ParsePrototype();
  26. static std::unique_ptr<FunctionAST> ParseDefinition();
  27. static std::unique_ptr<FunctionAST> ParseTopLevelExpr();
  28. static std::unique_ptr<PrototypeAST> ParseExtern();
  29. static void HandleDefinition();
  30. static void HandleExtern();
  31. static void HandleTopLevelExpression();
  32. void MainLoop();
  33. }
  34. #endif