swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 1 | #include <QCoreApplication> |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 2 | #include <QCommandLineParser> |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 3 | #include <QDebug> |
| 4 | |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 5 | #include "Matcher.h" |
| 6 | #include "Token.h" |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 7 | #include "AstNode.h" |
| 8 | #include "Parser.h" |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 9 | #include "Evaluator.h" |
| 10 | #include "VarContext.h" |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 11 | #include "Repl.h" |
swissChili | 9dddbf7 | 2021-12-08 23:03:25 -0800 | [diff] [blame] | 12 | #include "PPrint.h" |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 13 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 14 | #ifdef NO_IDE |
| 15 | using Application = QCoreApplication; |
| 16 | #else |
| 17 | #include "ide/IdeMain.h" |
| 18 | #endif |
| 19 | |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 20 | int g_numFailed = 0; |
| 21 | |
swissChili | 1060c0e | 2021-12-09 09:46:42 -0800 | [diff] [blame] | 22 | |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 23 | void testEval(QString function, QString expression, QString expected) |
| 24 | { |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 25 | Evaluator eval; |
| 26 | Parser funcParser(function), |
| 27 | exprParser(expression), |
| 28 | resParser(expected); |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 29 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 30 | Function func; |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 31 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 32 | QList<AstNode> expr; |
| 33 | ParseResult exprRet = exprParser.parseMany<AstNode>(&expr); |
| 34 | QList<Token> res; |
| 35 | ParseResult resRet = resParser.parseMany<Token>(&res); |
| 36 | ParseResult funcRet; |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 37 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 38 | QList<Token> result; |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 39 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 40 | exprParser.skip(); |
| 41 | resParser.skip(); |
| 42 | while ((funcRet = funcParser.parseFunctionDefinition(&func))) |
| 43 | { |
| 44 | eval.addFunction(func); |
| 45 | } |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 46 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 47 | funcParser.skip(); |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 48 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 49 | if (!exprRet || !resRet || funcRet.status() == ParseResult::INCOMPLETE) |
| 50 | { |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 51 | g_numFailed++; |
| 52 | qDebug() << "\n\033[31mTEST FAILS:\033[0m"; |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 53 | qDebug() << "Failed to fully parse expression, function or result"; |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame] | 54 | qDebug() << "Function:"; |
| 55 | sout(pprint(funcRet, funcParser)); |
| 56 | |
| 57 | qDebug() << "Expression:"; |
| 58 | sout(pprint(exprRet, exprParser)); |
| 59 | |
| 60 | qDebug() << "Result:"; |
| 61 | sout(pprint(resRet, resParser)); |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 62 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 63 | goto end; |
| 64 | } |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 65 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 66 | for (const AstNode &node : expr) |
| 67 | { |
| 68 | RuntimeResult rr = eval.evaluate(node, VarContext()); |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 69 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 70 | if (!rr.success()) |
| 71 | { |
| 72 | g_numFailed++; |
| 73 | qDebug() << "\n\033[31mTEST FAILS:\033[0m"; |
| 74 | qDebug() << "Runtime error while evaluating" << node; |
| 75 | qDebug() << rr; |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 76 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 77 | goto end; |
| 78 | } |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 79 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 80 | result.append(rr.result()); |
| 81 | } |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 82 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 83 | if (result != res) |
| 84 | { |
| 85 | g_numFailed++; |
| 86 | qDebug() << "\n\033[31mTEST FAILS:\033[0m"; |
| 87 | qDebug() << "Expected result" << res; |
| 88 | qDebug() << "Got" << result; |
| 89 | } |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 90 | |
| 91 | end: |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 92 | qDebug() << "\033[36mEvaluate\033[0m" << function << expression << "->" << pprint(result); |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 93 | } |
| 94 | |
swissChili | 1060c0e | 2021-12-09 09:46:42 -0800 | [diff] [blame] | 95 | void testEval(QString function, QString expression, QList<Token> expected) |
| 96 | { |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 97 | testEval(function, expression, pprint(expected)); |
swissChili | 1060c0e | 2021-12-09 09:46:42 -0800 | [diff] [blame] | 98 | } |
| 99 | |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 100 | void testEval(QString expression, QString expected) |
| 101 | { |
| 102 | testEval("", expression, expected); |
| 103 | } |
| 104 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 105 | void testMatch(const QString &test, bool shouldBe, const MatchResult &result) |
| 106 | { |
| 107 | if (result.success != shouldBe) |
| 108 | { |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 109 | g_numFailed++; |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 110 | qDebug() << "\n\033[31mTEST FAILS:\033[0m"; |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 111 | qDebug() << "with context" << result.context; |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 112 | } |
| 113 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 114 | qDebug() << "\033[36mMatchResult\033[0m" << test << result.success; |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 115 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 116 | if (result.success != shouldBe) |
| 117 | { |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 118 | qDebug() << ""; |
| 119 | } |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 120 | } |
| 121 | |
swissChili | 682e7bc | 2021-12-07 09:04:54 -0800 | [diff] [blame] | 122 | void testMatch(QString data, QString pattern, bool shouldBe = true) |
| 123 | { |
| 124 | Parser dataParser(data), |
| 125 | patternParser(pattern); |
| 126 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 127 | QList<Token> parsedData, parsedPattern; |
| 128 | |
| 129 | dataParser.parseMany<Token>(&parsedData); |
| 130 | patternParser.parseMany<Token>(&parsedPattern); |
swissChili | 847a78c | 2021-12-09 17:44:52 -0800 | [diff] [blame] | 131 | |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 132 | testMatch(pattern + " = " + data, shouldBe, |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 133 | match(parsedData, parsedPattern, VarContext())); |
swissChili | 682e7bc | 2021-12-07 09:04:54 -0800 | [diff] [blame] | 134 | } |
| 135 | |
swissChili | 9dddbf7 | 2021-12-08 23:03:25 -0800 | [diff] [blame] | 136 | void testParseAst(QString string, QList<AstNode> equals = {}) |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 137 | { |
| 138 | Parser parser{string}; |
| 139 | |
swissChili | 847a78c | 2021-12-09 17:44:52 -0800 | [diff] [blame] | 140 | QList<AstNode> result; |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 141 | parser.parseMany<AstNode>(&result); |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 142 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 143 | if (!equals.empty() && result != equals) |
| 144 | { |
swissChili | 9dddbf7 | 2021-12-08 23:03:25 -0800 | [diff] [blame] | 145 | g_numFailed++; |
| 146 | qDebug() << "\n\033[31mTEST FAILS:\033[0m"; |
| 147 | qDebug() << "Expected" << pprint(equals); |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 148 | } |
swissChili | 9dddbf7 | 2021-12-08 23:03:25 -0800 | [diff] [blame] | 149 | |
| 150 | qDebug() << "\033[36mParse\033[0m" << string << pprint(result); |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 151 | } |
| 152 | |
swissChili | 8a581c6 | 2021-12-07 13:29:21 -0800 | [diff] [blame] | 153 | void testParseFunc(QString string) |
| 154 | { |
| 155 | Parser parser{string}; |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 156 | ParseResult ret; |
swissChili | 8a581c6 | 2021-12-07 13:29:21 -0800 | [diff] [blame] | 157 | |
| 158 | Function func; |
| 159 | |
swissChili | 847a78c | 2021-12-09 17:44:52 -0800 | [diff] [blame] | 160 | if (!(ret = parser.parseFunctionDefinition(&func))) |
swissChili | 8a581c6 | 2021-12-07 13:29:21 -0800 | [diff] [blame] | 161 | { |
| 162 | g_numFailed++; |
| 163 | qDebug() << "\n\033[31mTEST FAILS:\033[0m"; |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame] | 164 | sout(pprint(ret, parser)); |
swissChili | 8a581c6 | 2021-12-07 13:29:21 -0800 | [diff] [blame] | 165 | qDebug() << string; |
| 166 | } |
| 167 | else |
| 168 | { |
| 169 | qDebug() << "\033[36mFunction\033[0m"; |
| 170 | qDebug().noquote() << func; |
| 171 | } |
| 172 | } |
| 173 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 174 | int testResults() |
| 175 | { |
| 176 | if (g_numFailed == 0) |
| 177 | { |
| 178 | qDebug() << "\033[32mALL TESTS SUCCEEDED\033[0m"; |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | qDebug().nospace() << "\033[31m" << g_numFailed << " TESTS FAILED\033[0m"; |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | return g_numFailed; |
| 186 | } |
| 187 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 188 | void testAllMatches() |
| 189 | { |
| 190 | testMatch("a = a", true, match({Token('a')}, {Token('a')}, VarContext())); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 191 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 192 | testMatch("s.a = y", true, match({Token('y')}, {Token('s', "a")}, VarContext())); |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 193 | |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 194 | LTok sameTwo = {Token('s', "a"), Token('s', "a")}; |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 195 | testMatch("s.a s.a = aa", true, match({Token('a'), Token('a')}, sameTwo, VarContext())); |
| 196 | testMatch("s.a s.a = ab", false, match({Token('a'), Token('b')}, sameTwo, VarContext())); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 197 | |
| 198 | LTok sameStartEnd = { |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 199 | Token('s', "a"), |
| 200 | Token('e', "middle"), |
| 201 | Token('s', "a")}; |
| 202 | testMatch("s.a e.middle s.a = aea", true, |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 203 | match({Token('a'), Token('e'), Token('a')}, sameStartEnd, VarContext())); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 204 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 205 | testMatch("s.a e.middle s.a = aef Hi a", true, |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 206 | match({Token('a'), Token('e'), Token('f'), Token("Hi"), Token('a')}, sameStartEnd, VarContext())); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 207 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 208 | testMatch("s.a e.middle s.a = aef Hi c", false, |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 209 | match({Token('a'), Token('e'), Token('f'), Token("Hi"), Token('c')}, sameStartEnd, VarContext())); |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 210 | |
| 211 | LTok parenthesized = { |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 212 | Token(LTok({Token('s', "a")})), |
| 213 | Token('e', "Middle"), |
| 214 | Token('s', "a"), |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 215 | }; |
| 216 | LTok parenTest1 = { |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 217 | Token(LTok({Token('y')})), |
| 218 | Token('f'), |
| 219 | Token("MiddleStuff"), |
| 220 | Token('y')}; |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 221 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 222 | testMatch("(s.a) e.Middle s.a = (y)f MiddleStuff y", true, |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 223 | match(parenTest1, parenthesized, VarContext())); |
swissChili | 682e7bc | 2021-12-07 09:04:54 -0800 | [diff] [blame] | 224 | // testMatch("(y)f Middle-stuff y", "(s.a) e.Middle s.a"); |
swissChili | d17b5a1 | 2021-12-05 20:46:42 -0800 | [diff] [blame] | 225 | |
swissChili | 682e7bc | 2021-12-07 09:04:54 -0800 | [diff] [blame] | 226 | testMatch("(a)", "(a)"); |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 227 | testMatch("hello", "s.A e.Rest"); |
| 228 | testMatch("123", "123"); |
| 229 | testMatch("(123)", "t.a"); |
| 230 | testMatch("(123)", "(s.a)"); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 231 | } |
| 232 | |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 233 | void testAllParses() |
| 234 | { |
swissChili | 682e7bc | 2021-12-07 09:04:54 -0800 | [diff] [blame] | 235 | testParseAst("all symbols"); |
| 236 | testParseAst("Identifier symbols Identifier"); |
| 237 | testParseAst("s.A"); |
| 238 | testParseAst("(s.A) Variable-quoted"); |
| 239 | testParseAst("<Func-name a b (c)>"); |
| 240 | testParseAst("<Prout hi>"); |
| 241 | testParseAst("(Prout hi)"); |
| 242 | testParseAst("(<Prout hi>)"); |
| 243 | testParseAst("<If T Then (<Prout hi>) Else (<Prout sorry>)>"); |
| 244 | testParseAst("(s.a) e.Middle s.a"); |
swissChili | 8a581c6 | 2021-12-07 13:29:21 -0800 | [diff] [blame] | 245 | testParseAst("Hello; Goodbye"); |
| 246 | testParseAst("Key = Value"); |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 247 | testParseAst("123", {AstNode("123", 10)}); |
| 248 | testParseAst("12 00", {AstNode::fromInteger(12), AstNode::fromInteger(0)}); |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame] | 249 | testParseAst("s.A s.B", {AstNode('s', "A"), AstNode('s', "B")}); |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 250 | testParseAst("a '=' b", {AstNode('a'), AstNode('='), AstNode('b')}); |
| 251 | testParseAst("'This\\'<>#$@#^%\\n' 'another $3543543'"); |
swissChili | 8a581c6 | 2021-12-07 13:29:21 -0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | void testAllFunctionDefs() |
| 255 | { |
| 256 | testParseFunc("Test { = HI; }"); |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 257 | testParseFunc("Palindrome { = T; s.A = T; s.A e.Middle s.A = <Palindrome e.Middle>; e.Ignored = F; } "); |
swissChili | 07d325f | 2021-12-08 20:02:05 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void testAllEvals() |
| 261 | { |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 262 | testEval("First {s.A e.Rest = s.A;}", "<First hello>", "h"); |
| 263 | testEval("Number { = 123; }", "<Number>", QList<Token>{Token::fromInteger(123)}); |
swissChili | 918557c | 2022-02-20 20:16:34 -0800 | [diff] [blame] | 264 | testEval("<Br Name '=' Jim> <Dg Name>", "Jim"); |
| 265 | testEval("<Br A '=' hello> <Br A '=' 'good bye'> <Dg A> <Dg A>", "'good byehello'"); |
swissChili | c71acc6 | 2021-12-07 08:03:37 -0800 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | int main(int argc, char *argv[]) |
| 269 | { |
swissChili | e386bc7 | 2022-02-24 21:31:31 -0800 | [diff] [blame] | 270 | QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); |
| 271 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 272 | Application a(argc, argv); |
| 273 | a.setApplicationName("REFAL"); |
| 274 | a.setApplicationVersion("1.0-a1"); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 275 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 276 | QCommandLineParser cli; |
| 277 | cli.setApplicationDescription("REFAL interpreter"); |
| 278 | cli.addHelpOption(); |
| 279 | cli.addVersionOption(); |
swissChili | 3e98c06 | 2021-12-04 22:07:38 -0800 | [diff] [blame] | 280 | |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame] | 281 | cli.addPositionalArgument("script", "REFAL script to run"); |
| 282 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 283 | QCommandLineOption testOption(QStringList{"t", "test"}, "Run test suite."); |
| 284 | cli.addOption(testOption); |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 285 | QCommandLineOption replOption(QStringList({"r", "repl"}), "Start CLI REPL"); |
| 286 | cli.addOption(replOption); |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 287 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 288 | cli.process(a); |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 289 | |
swissChili | 323883d | 2022-02-20 16:35:23 -0800 | [diff] [blame] | 290 | if (cli.positionalArguments().length() > 0) |
| 291 | { |
| 292 | qDebug() << "Running script" << cli.positionalArguments()[0]; |
| 293 | } |
| 294 | else if (cli.isSet(testOption)) |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 295 | { |
| 296 | testAllMatches(); |
| 297 | qDebug() << ""; |
| 298 | testAllParses(); |
| 299 | qDebug() << ""; |
| 300 | testAllFunctionDefs(); |
| 301 | qDebug() << ""; |
| 302 | testAllEvals(); |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 303 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 304 | qDebug() << ""; |
swissChili | 923bd53 | 2021-12-08 22:48:58 -0800 | [diff] [blame] | 305 | |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 306 | return testResults(); |
| 307 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 308 | else if (cli.isSet(replOption)) |
swissChili | 732628e | 2022-02-25 10:35:56 -0800 | [diff] [blame] | 309 | { |
| 310 | Repl repl; |
| 311 | repl.start(); |
| 312 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 313 | else |
| 314 | { |
| 315 | return ideMain(&a); |
| 316 | } |
swissChili | 7babd92 | 2021-12-02 22:46:48 -0800 | [diff] [blame] | 317 | } |