sokobo
Loading...
Searching...
No Matches
cli.h
1#pragma once
2#include <map>
3#include <memory>
4#include <string>
5#include <vector>
6
7#include "complex_number.h"
8#include "expression.h"
9#include "matrix.h"
10#include "polynomial.h"
11
13{
14private:
15 // Command handlers
16 void showHelp();
17 void showHelpMatrices();
18 std::vector<std::string> split(const std::string& str);
19
20 // Expression commands
21 void handleExpression(const std::vector<std::string>& tokens);
22 void handleDerivative(const std::vector<std::string>& tokens);
23 void handleIntegral(const std::vector<std::string>& tokens);
24 void handleLimit(const std::vector<std::string>& tokens);
25 void handleSeries(const std::vector<std::string>& tokens);
26
27 void handlePolynomial(const std::vector<std::string>& tokens);
28
29 void handlePolynomialAdd(const std::vector<std::string>& tokens);
30
31 // Polynomial commands
32 // void handlePolynomial(const std::vector<std::string>& tokens);
33 void handlePolynomialEvaluate(const std::vector<std::string>& tokens);
34 // void handlePolynomialAdd(const std::vector<std::string>& tokens);
35 // void handlePolynomialMultiply(const std::vector<std::string>& tokens);
36 // void handlePolynomialGCD(const std::vector<std::string>& tokens);
37 void handlePolynomialRoots(const std::vector<std::string>& tokens);
38 // void handlePolynomialFactor(const std::vector<std::string>& tokens);
39
40 // Complex number commands
41 void handleComplex(const std::vector<std::string>& tokens);
42 void handleComplexAdd(const std::vector<std::string>& tokens);
43 void handleComplexMultiply(const std::vector<std::string>& tokens);
44 void handleComplexPower(const std::vector<std::string>& tokens);
45 void handleComplexRoots(const std::vector<std::string>& tokens);
46
47 // Matrix commands
48 void handleMatrix(const std::vector<std::string>& tokens);
49 void handleMatrixRaw(const std::vector<std::string>& tokens);
50 void handleMatrixAdjoint(const std::vector<std::string>& tokens);
51 void handleMatrixDisplay(const std::vector<std::string>& tokens);
52 void handleMatrixRank(const std::vector<std::string>& tokens);
53 void handleMatrixSet(const std::vector<std::string>& tokens);
54 void handleMatrixDeterminant(const std::vector<std::string>& tokens);
55 void handleMatrixInverse(const std::vector<std::string>& tokens);
56 void handleMatrixEigenvalues(const std::vector<std::string>& tokens);
57 void handleMatrixEigenvectors(const std::vector<std::string>& tokens);
58
59 // Transform commands
60 void handleLaplace(const std::vector<std::string>& tokens);
61 void handleFourier(const std::vector<std::string>& tokens);
62
63 // Differential equation commands
64 void handleODE(const std::vector<std::string>& tokens);
65 void handlePDE(const std::vector<std::string>& tokens);
66
67 // Numerical methods
68 /* void handleRootFind(const std::vector<std::string>& tokens);
69 void handleOptimize(const std::vector<std::string>& tokens);
70 void handleInterpolate(const std::vector<std::string>& tokens);
71 */
72 // Utility commands
73 void listObjects();
74 void clearAll();
75
76 // std::map<std::string, std::shared_ptr<Expression>> expressions;
77
78 // Parser helper methods
79 std::shared_ptr<Expression> parseExpression(const std::string& exprStr);
80 std::string removeWhitespace(const std::string& str);
81 std::shared_ptr<Expression> parseAddSub(const std::string& expr, size_t& pos);
82 std::shared_ptr<Expression> parseMulDiv(const std::string& expr, size_t& pos);
83 std::shared_ptr<Expression> parsePower(const std::string& expr, size_t& pos);
84 std::shared_ptr<Expression> parseFactor(const std::string& expr, size_t& pos);
85 std::shared_ptr<Expression> parseNumber(const std::string& expr, size_t& pos);
86 std::shared_ptr<Expression> parseVariableOrFunction(const std::string& expr,
87 size_t& pos);
88
89public:
90 std::map<std::string, Polynomial> polynomials;
91 std::map<std::string, ComplexNumber> complexNumbers;
92 std::map<std::string, Matrix<float>> matrices;
93 std::map<std::string, std::shared_ptr<Expression>> expressions;
94 std::map<std::string, double> variables;
95 void run();
96};
Definition: cli.h:13