swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <QString> |
| 4 | #include <QList> |
| 5 | |
| 6 | #include "Token.h" |
| 7 | #include "AstNode.h" |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame^] | 8 | #include "Parser.h" |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 9 | |
| 10 | template <typename T> |
| 11 | QString pprint(T val); |
| 12 | |
| 13 | template <> |
| 14 | QString pprint<Token>(Token val); |
| 15 | |
| 16 | template <> |
| 17 | QString pprint<AstNode>(AstNode val); |
| 18 | |
| 19 | template <typename T> |
| 20 | QString pprint(QList<T> val) |
| 21 | { |
| 22 | QStringList out; |
| 23 | |
| 24 | for (const T &v : val) |
| 25 | out.append(static_cast<QString>(v)); |
| 26 | |
| 27 | return out.join(" "); |
| 28 | } |
| 29 | |
| 30 | template <typename T> |
| 31 | QString pprint(T val) |
| 32 | { |
| 33 | return static_cast<QString>(val); |
| 34 | } |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame^] | 35 | |
| 36 | QString pprint(ParseResult val, const Parser &parser); |
| 37 | |
| 38 | void sout(QString string); |