swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <QString> |
| 4 | #include <QList> |
| 5 | |
| 6 | #include "Evaluator.h" |
| 7 | #include "AstNode.h" |
swissChili | c046cdf | 2021-12-09 19:59:51 -0800 | [diff] [blame] | 8 | #include "Parser.h" |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 9 | |
| 10 | class Repl |
| 11 | { |
| 12 | public: |
| 13 | Repl(); |
| 14 | |
| 15 | void start(); |
| 16 | char *prompt(); |
| 17 | |
| 18 | protected: |
| 19 | QString readLine(); |
swissChili | bd2a90d | 2021-12-09 10:36:14 -0800 | [diff] [blame] | 20 | void addHistory(QString line); |
swissChili | c046cdf | 2021-12-09 19:59:51 -0800 | [diff] [blame] | 21 | ParseResult trySpecialCase(QString line); |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame] | 22 | ParseResult tryEvaluate(Parser &parser, QList<AstNode> *expr); |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 23 | |
| 24 | Evaluator _eval; |
| 25 | |
| 26 | bool _running = true; |
| 27 | }; |