Parser.h 1.1 KB

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