Lexer.h 555 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef _LEXER_H
  2. #define _LEXER_H
  3. #include <cctype>
  4. #include <cstdio>
  5. #include <map>
  6. #include <string>
  7. #include <vector>
  8. #include "Ast.h"
  9. namespace lexer{
  10. // The lexer returns tokens [0-255] if it is an unknown character, otherwise one
  11. // of these for known things.
  12. enum Token {
  13. tok_eof = -1,
  14. // commands
  15. tok_def = -2,
  16. tok_extern = -3,
  17. // primary
  18. tok_identifier = -4,
  19. tok_number = -5
  20. };
  21. struct LexerObjects {
  22. public:
  23. static std::string IdentifierStr; // Filled in if tok_identifier
  24. static double NumVal;
  25. };
  26. int gettok();
  27. }
  28. #endif