swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame^] | 1 | #pragma once |
| 2 | |
| 3 | #include <QList> |
| 4 | #include <QChar> |
| 5 | |
| 6 | class Token { |
| 7 | public: |
| 8 | Token(); |
| 9 | Token(const Token &other); |
| 10 | |
| 11 | explicit Token(QChar symbol); |
| 12 | explicit Token(QString &&identifier); |
| 13 | explicit Token(QList<Token> &&parenthesized); |
| 14 | Token(char varType, const QString &&name); |
| 15 | |
| 16 | bool operator ==(const Token &other); |
| 17 | |
| 18 | ~Token(); |
| 19 | |
| 20 | bool isSym(); |
| 21 | bool isIdent(); |
| 22 | bool isParen(); |
| 23 | bool isVar(); |
| 24 | |
| 25 | QList<Token> parenContent(); |
| 26 | |
| 27 | private: |
| 28 | enum Type { |
| 29 | SYM, IDENT, PAREN, VAR, |
| 30 | }; |
| 31 | |
| 32 | int _type = 0; |
| 33 | QString _stringVal = ""; |
| 34 | QList<Token> *_listVal = nullptr; |
| 35 | QChar _charVal = 0; |
| 36 | }; |