blob: a0a5eaa99c8563bf4b945f05060c35ca5444859a [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);
13 explicit Token(QList<Token> &&parenthesized);
14 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
19 bool isSym();
20 bool isIdent();
21 bool isParen();
22 bool isVar();
23
24 QList<Token> parenContent();
25
swissChili3e98c062021-12-04 22:07:38 -080026 char varType() const;
27 const QString &name() const;
28
swissChili7babd922021-12-02 22:46:48 -080029private:
30 enum Type {
31 SYM, IDENT, PAREN, VAR,
32 };
33
34 int _type = 0;
35 QString _stringVal = "";
swissChili3e98c062021-12-04 22:07:38 -080036 QList<Token> _listVal;
swissChili7babd922021-12-02 22:46:48 -080037 QChar _charVal = 0;
38};
swissChili3e98c062021-12-04 22:07:38 -080039
40using LTok = QList<Token>;