blob: 4835de0ec38d9c52dfed4639f57ea9f49b44b185 [file] [log] [blame]
swissChili7babd922021-12-02 22:46:48 -08001#pragma once
2
3#include <QList>
4#include <QChar>
5
6class Token {
7public:
8 Token();
9 Token(const Token &other);
10
11 explicit Token(QChar symbol);
12 explicit Token(QString &&identifier);
swissChilid17b5a12021-12-05 20:46:42 -080013 explicit Token(QList<Token> parenthesized);
swissChili7babd922021-12-02 22:46:48 -080014 Token(char varType, const QString &&name);
15
swissChili3e98c062021-12-04 22:07:38 -080016 bool operator ==(const Token &other) const;
17 bool operator !=(const Token &other) const;
swissChili7babd922021-12-02 22:46:48 -080018
swissChilid17b5a12021-12-05 20:46:42 -080019 bool isSym() const;
20 bool isIdent() const;
21 bool isParen() const;
22 bool isVar() const;
swissChili7babd922021-12-02 22:46:48 -080023
24 QList<Token> parenContent();
25
swissChili3e98c062021-12-04 22:07:38 -080026 char varType() const;
27 const QString &name() const;
28
swissChilid17b5a12021-12-05 20:46:42 -080029 operator QString() const;
30
swissChili7babd922021-12-02 22:46:48 -080031 enum Type {
32 SYM, IDENT, PAREN, VAR,
33 };
34
swissChilid17b5a12021-12-05 20:46:42 -080035 static QString typeToString(int type);
36
37 int type() const;
38
39private:
swissChili7babd922021-12-02 22:46:48 -080040 int _type = 0;
41 QString _stringVal = "";
swissChili3e98c062021-12-04 22:07:38 -080042 QList<Token> _listVal;
swissChili7babd922021-12-02 22:46:48 -080043 QChar _charVal = 0;
44};
swissChili3e98c062021-12-04 22:07:38 -080045
46using LTok = QList<Token>;