Guest User

Untitled

a guest
Jul 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #ifndef TOKEN_H
  2. #define TOKEN_H
  3.  
  4. using namespace std;
  5.  
  6. enum TokenType {
  7. EOL, // end of line the same as the original
  8. VALUE, // constant the same as the original
  9. OPAREN, // ( the same as the original
  10. CPAREN, // ) the same as the original
  11.  
  12. NOT, // ! (logical negation) reserved for PROG 5
  13. BIT_COMP, // ~ reserved for PROG 5
  14.  
  15. UN_MINUS, // - reserved for PROG 5
  16. UN_PLUS, // + reserved for PROG 5
  17.  
  18. MULT, // * the same as the original
  19. DIV, // / the same as the original
  20. MODULUS, // %
  21.  
  22. PLUS, // - the same as the original
  23. MINUS, // + the same as the original
  24.  
  25. SHIFT_L, // <<
  26. SHIFT_R, // >>
  27. LT, // <
  28. LE, // <=
  29. GT, // >
  30. GE, // >=
  31.  
  32. EQUAL, // ==
  33. NOTEQUAL, // !=
  34.  
  35. BIT_AND, // &
  36. BIT_EOR, // ^
  37. BIT_IOR, // |
  38.  
  39. LOG_AND, // &&
  40. LOG_OR, // ||
  41.  
  42. //new to implement
  43. VAR_A, // variable a
  44. VAR_B, // variable b
  45. VAR_C // variable c
  46.  
  47. };
  48.  
  49. // the class definition is the same as the original
  50. template <class NumericType>
  51. class Token {
  52. public:
  53. Token( TokenType tt = EOL, const NumericType & nt = 0 )
  54. : theType( tt ), theValue( nt ) {
  55. }
  56.  
  57. TokenType getType( ) const {
  58. return theType;
  59. }
  60. const NumericType &getValue( ) const {
  61. return theValue;
  62. }
  63.  
  64. private:
  65. TokenType theType;
  66. NumericType theValue;
  67. };
  68.  
  69. #endif
Add Comment
Please, Sign In to add comment