Lexer.h 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef _LEXER_H
  2. #define _LEXER_H
  3. // Standard includes
  4. #include <string>
  5. // LLVM includes
  6. #include "llvm/IR/IRBuilder.h"
  7. #include "llvm/IR/DIBuilder.h"
  8. // Local includes
  9. //#include "Ast.h"
  10. namespace lexer {
  11. // The lexer returns tokens [0-255] if it is an unknown character, otherwise one
  12. // of these for known things.
  13. enum Token {
  14. tok_eof = -1,
  15. // commands
  16. tok_def = -2,
  17. tok_extern = -3,
  18. // primary
  19. tok_identifier = -4,
  20. tok_number = -5,
  21. // control
  22. tok_if = -6,
  23. tok_then = -7,
  24. tok_else = -8,
  25. tok_for = -9,
  26. tok_in = -10,
  27. // operators
  28. tok_binary = -11,
  29. tok_unary = -12,
  30. // var definition
  31. tok_var = -13
  32. };
  33. //static llvm::IRBuilder<> ast::AstObjects::Builder(getGlobalContext());
  34. struct SourceLocation {
  35. int Line;
  36. int Col;
  37. };
  38. static SourceLocation CurLoc;
  39. static SourceLocation LexLoc = {1, 0};
  40. static int advance();
  41. struct LexerObjects {
  42. public:
  43. static std::string IdentifierStr; // Filled in if tok_identifier
  44. static double NumVal;
  45. };
  46. int gettok();
  47. }
  48. #endif