Fixed minor stuff

This commit is contained in:
Marco Cetica 2023-11-03 11:57:19 +01:00
parent 195fb4476a
commit 75b39b99a3
Signed by: marco
GPG Key ID: 45060A949E90D0FD
5 changed files with 9 additions and 10 deletions

View File

@ -28,7 +28,6 @@ Some of the supported features are:
- Basic arithmetical operations(`+`, `-`, `*`, `/`, `^`, `%`);
- Scientific notation support(`5e3` -> `5000`);
- Trigonometrical functions(`sin`, `cos`, `tan`);
- Base conversion(printBin `pb`, printOctal `po`, printHex `px`);
- Factorial and constants(`!`, `pi`, `e`);
- Stack operations:
- Print top element(`p`, `P`);
@ -60,7 +59,7 @@ A new binary called `dc` will be created in your local folder.
To generate a man page from the `man.md` document, use the following command(note: needs pandoc):
```sh
$> pandoc man.md -s -t man > dc.1
$> pandoc man.md -s -t man > dc.1
```
## Usage

View File

@ -8,8 +8,8 @@
class Evaluate {
public:
Evaluate(std::vector<std::string> expr, std::unordered_map<char, Register> &regs, stack_t &stack)
: expr(expr), regs(regs), stack(stack) {}
Evaluate(const std::vector<std::string> expr, std::unordered_map<char, Register> &regs, stack_t &stack)
: expr(std::move(expr)), regs(regs), stack(stack) {}
Evaluate(std::unordered_map<char, Register> &regs, stack_t &stack)
: regs(regs), stack(stack) {}
std::optional<std::string> eval();

View File

@ -8,10 +8,10 @@ enum class Operator {
class Macro : public IOperation {
public:
Macro(OPType op_type, Operator op, char dc_register, std::unordered_map<char, Register> &regs)
: op_type(op_type), op(op), dc_register(dc_register), regs(regs) {}
Macro(OPType op_type, std::unordered_map<char, Register> &regs)
: op_type(op_type), regs(regs) {}
Macro(const OPType op_type, const Operator op, const char dc_register, std::unordered_map<char, Register> &regs)
: op_type(std::move(op_type)), op(std::move(op)), dc_register(std::move(dc_register)), regs(regs) {}
Macro(const OPType op_type, std::unordered_map<char, Register> &regs)
: op_type(std::move(op_type)), regs(regs) {}
std::optional<std::string> exec(stack_t &stack) override;
static std::vector<std::string> split(std::string str);

View File

@ -4,7 +4,7 @@
class Math : public IOperation {
public:
Math(OPType op_type) : op_type(op_type) {}
Math(const OPType op_type) : op_type(std::move(op_type)) {}
std::optional<std::string> exec(stack_t &stack) override;
private:

View File

@ -4,7 +4,7 @@
class Stack : public IOperation {
public:
Stack(OPType op_type) : op_type(op_type) {}
Stack(const OPType op_type) : op_type(std::move(op_type)) {}
std::optional<std::string> exec(stack_t &stack) override;
private: