Lexer.h 639 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. };
  26. struct LexerObjects {
  27. public:
  28. static std::string IdentifierStr; // Filled in if tok_identifier
  29. static double NumVal;
  30. };
  31. int gettok();
  32. }
  33. #endif