Lexer.h 676 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef _LEXER_H
  2. #define _LEXER_H
  3. // Standard includes
  4. #include <string>
  5. namespace lexer{
  6. // The lexer returns tokens [0-255] if it is an unknown character, otherwise one
  7. // of these for known things.
  8. enum Token {
  9. tok_eof = -1,
  10. // commands
  11. tok_def = -2,
  12. tok_extern = -3,
  13. // primary
  14. tok_identifier = -4,
  15. tok_number = -5,
  16. // control
  17. tok_if = -6,
  18. tok_then = -7,
  19. tok_else = -8,
  20. tok_for = -9,
  21. tok_in = -10,
  22. // operators
  23. tok_binary = -11,
  24. tok_unary = -12,
  25. // var definition
  26. tok_var = -13
  27. };
  28. struct LexerObjects {
  29. public:
  30. static std::string IdentifierStr; // Filled in if tok_identifier
  31. static double NumVal;
  32. };
  33. int gettok();
  34. }
  35. #endif