Lexer.h 585 B

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