Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. enum class LexemType {
  6. num, chr, str, id, lpar, rpar, lbrace, rbrace, lbracket, rbracket,
  7. semicolon, comma, colon, opassign, opplus, opminus, opmult, opinc, opeq, opne, oplt,
  8. opgt, ople, opnot, opor, opand, kwint, kwchar, kwif, kwelse, kwswitch, kwcase, kwwhile,
  9. kwfor, kwreturn, kwin, kwout, eof, error
  10. };
  11.  
  12.  
  13. class Token {
  14. private:
  15.  
  16. LexemType _type;
  17. int _value;
  18. string _str;
  19.  
  20. public:
  21.  
  22. // Constructors
  23. Token(LexemType type) : _type(type) {};
  24.  
  25. Token(int value) : _value(value) {};
  26.  
  27. Token(LexemType type, const string &str) : _type(type), _str(str) {};
  28.  
  29. Token(char c) : _value(c) {};
  30.  
  31. // Getters
  32. int value() { return _value; };
  33.  
  34. string str() { return _str; };
  35.  
  36. LexemType type() {};
  37.  
  38. // Other
  39.  
  40. void print(ostream &stream) {
  41. };
  42.  
  43. string LexemTypeToStr(LexemType type) {
  44. switch (type) {
  45. case LexemType::num:
  46. return "num";
  47.  
  48. case LexemType::chr:
  49. return "chr";
  50.  
  51. case LexemType::str:
  52. return "str";
  53. }
  54. };
  55. };
  56.  
  57.  
  58. int main() {
  59.  
  60.  
  61. return 0;
  62. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement