Parser.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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> 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