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