swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 1 | #pragma once |
2 | |||||
3 | #include <QMap> | ||||
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 4 | #include <QDebug> |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 5 | #include "Token.h" |
6 | |||||
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 7 | class VarContext |
8 | { | ||||
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 9 | public: |
10 | VarContext() = default; | ||||
11 | VarContext(VarContext const &other) noexcept; | ||||
12 | |||||
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 13 | void add(char t, const QString &name, const Token &value); |
14 | void add(char t, const QString &name, const QList<Token> &value); | ||||
15 | |||||
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 16 | char exists(const QString &name); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 17 | Token singleVar(const QString &name); |
18 | QList<Token> expressionVar(const QString &name); | ||||
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 19 | |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 20 | friend QDebug &operator <<(QDebug &debug, const VarContext &ctx); |
21 | |||||
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 22 | private: |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 23 | struct Var |
24 | { | ||||
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 25 | Var() = default; |
26 | |||||
27 | char t = 0; | ||||
28 | Token value; | ||||
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 29 | QList<Token> expressionValue; |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 30 | }; |
31 | |||||
32 | QMap<QString, Var> _vars; | ||||
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 33 | }; |
34 | |||||
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 35 | QDebug &operator <<(QDebug &debug, const VarContext &ctx); |