Skip to content

Commit 1c31678

Browse files
committed
Add logo, more information, etc.
1 parent 5b66ade commit 1c31678

File tree

1 file changed

+62
-41
lines changed

1 file changed

+62
-41
lines changed

README.md

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# MathParser.lua - A Robust Lua Math Parser
1+
<div align="center">
22

3-
> A comprehensive, user-friendly math parser for Lua, featuring support for variables, functions and customizable operator precedence.
3+
<img src="https://github.com/ByteXenon/MathParser.lua/assets/125568681/7c85601d-1218-414b-9545-f5e57d48c061" alt="MathParser.lua logo" width="200" height="200">
4+
5+
# 🚀 MathParser.lua - A Robust Lua Math Parser
6+
7+
A comprehensive, user-friendly math parser for Lua, featuring support for variables, functions and customizable operators and operator precedence.
48

59
![Lua](https://img.shields.io/badge/Lua-5.1%2C%205.2%2C%205.3%2C%205.4-blue?style=for-the-badge&logo=lua)
610
![GitHub stars](https://img.shields.io/github/stars/ByteXenon/MathParser.lua?style=for-the-badge)
@@ -10,34 +14,44 @@
1014
![Tests Passing](https://img.shields.io/badge/Tests-Passing-green?style=for-the-badge)
1115
![100% Test Coverage](https://img.shields.io/badge/Test%20Coverage-100%25-green?style=for-the-badge)
1216

13-
MathParser.lua is a robust and comprehensive math parser for Lua, designed with a focus on simplicity, elegance, and user-friendliness. Each function in the codebase is well-documented, making it easy to read, understand, and modify. It supports a wide range of mathematical operations, from basic arithmetic to complex expressions, and allows for the addition of custom functions, variables, operators, and operator precedence levels.
17+
</div>
18+
19+
## 🎯 Introduction
20+
21+
Welcome to MathParser.lua, a comprehensive math parser tailored specifically for Lua. With its structured design and well-commented code, this parser is accessible to both newcomers and seasoned developers alike.
22+
23+
MathParser.lua is capable of handling a wide array of mathematical problems, providing a reliable solution for your computational needs. But it doesn't stop there. It offers a high degree of customization, allowing you to extend its functionality by adding your own functions, variables, and operators. You even have the flexibility to alter the precedence of operations to suit your needs. For instance, you can configure the parser to prioritize addition over multiplication - a level of customization that truly sets MathParser.lua apart from other math parsers.
1424

15-
This project boasts a full 100% test coverage. It has been thoroughly tested and confirmed to work seamlessly on Lua versions 5.1, 5.2, 5.3, 5.4, as well as on LuaJIT and Luau.
25+
One of the defining features of MathParser.lua is its thorough test coverage. We've ensured that every line of code is put through rigorous testing, guaranteeing its reliability and robustness. Furthermore, it's compatible with various Lua versions, starting from Lua-5.1, including LuaJIT. It's even compatible with Luau, making it a viable choice for your Roblox projects.
1626

17-
## Table of Contents:
18-
- **[MathParser.lua](#mathparserlua---a-robust-lua-math-parser)**
19-
- **[Table of Contents](#table-of-contents)**
20-
- **[Features](#features)**
21-
- **[Usage](#usage)**
22-
- **[Basic Usage](#basic-usage)**
23-
- **[Advanced Usage](#advanced-usage)**
24-
- **[License](#license)**
27+
## 📖 Table of Contents
2528

26-
**Quick Links:** **[API](./src/MathParser.lua)** | **[License](./LICENSE)** | **[Documentation](./docs/Documentation.md)** | **[Example](./example.lua)**
29+
- [🚀 MathParser.lua - A Robust Lua Math Parser](#-mathparserlua---a-robust-lua-math-parser)
30+
- [🎯 Introduction](#-introduction)
31+
- [📖 Table of Contents](#-table-of-contents)
32+
- [🎁 Features](#-features)
33+
- [🛠 Usage](#-usage)
34+
- [🔰 Getting Started](#-getting-started)
35+
- [🔱 Advanced Usage](#-advanced-usage)
36+
- [🛣️ Roadmap](#️-roadmap)
37+
- [📜 License](#-license)
2738

28-
## Features
39+
**Quick Links:** [🔗 API](./src/MathParser.lua) | [📄 License](./LICENSE) | [📚 Documentation](./docs/Documentation.md) | [📝 Example](./example.lua)
2940

30-
- **Simplicity**: MathParser.lua offers a user-friendly [API](./src/MathParser.lua) that is easy to understand and use.
31-
- **Lightweight**: Despite its powerful features, MathParser.lua is lightweight and has no external dependencies.
32-
- **Efficient**: MathParser.lua is also optimized for speed, ensuring fast computations even with complex mathematical expressions.
33-
- **Customizable**: With MathParser.lua, you have the flexibility to modify operator precedence and add new operators, tailoring the parser to your specific needs.
41+
## 🎁 Features
3442

35-
## Usage
43+
1. **User-Friendly**: MathParser.lua boasts an intuitive API, making it a breeze to integrate into your projects. Its comprehensive documentation provides clear examples and explanations, while its error messages are designed to pinpoint the exact location of issues, reducing debugging time.
44+
2. **Safe and Secure**: Safety is a priority with MathParser.lua. It avoids the use of the `load` function, which can execute any Lua code. Instead, it employs a custom parser to process input expressions, ensuring only valid mathematical operations are executed. If an input is invalid or potentially harmful, MathParser.lua throws an error, providing detailed information about the issue.
45+
3. **Compact and Efficient**: MathParser.lua is a lean project with no external dependencies, making it easy to incorporate into your codebase. Its compact size doesn't compromise its functionality, offering a powerful tool that's easy to understand and modify.
46+
4. **Highly Customizable**: MathParser.lua offers extensive customization options. You can add custom functions, variables, and operators, and even change the order in which operations are done. This flexibility allows you to tailor MathParser.lua to your specific needs, making it a versatile tool for a wide range of applications.
3647

37-
Here's a quick guide on how to use MathParser.lua:
48+
## 🛠 Usage
3849

39-
### Basic Usage
50+
MathParser.lua is a versatile tool that can handle everything from simple arithmetic to complex mathematical expressions. Whether you're integrating it into a large project or using it for quick calculations, here's a comprehensive guide to get you started.
4051

52+
### 🔰 Getting Started
53+
54+
Using MathParser.lua is as easy as 1-2-3. Here's a quick example to get you started:
4155
```lua
4256
local MathParser = require("MathParser")
4357

@@ -54,44 +68,35 @@ print(myParser:solve("x + 5")) -- Outputs: 10
5468
print(myParser:solve("(x + 5) * 2")) -- Outputs: 20
5569
```
5670

57-
### Advanced Usage
71+
It was just a simple example. For more advanced usage, let's move on to the next section.
72+
73+
### 🔱 Advanced Usage
5874

59-
In addition to basic arithmetic, MathParser.lua supports custom functions and operators. Here's an example of how to use these features:
75+
MathParser.lua is not just a simple math parser, it's a powerful tool that can be customized to suit your needs. It supports the addition of custom functions, variables, and operators, allowing you to extend its functionality beyond basic math operations. Let's use all these features to demonstrate how you can use MathParser.lua in more advanced scenarios.
6076

77+
Here's an example code snippet that demonstrates the advanced usage of MathParser.lua:
6178
```lua
6279
local MathParser = require("MathParser")
63-
64-
-- Create a new parser instance
6580
local myParser = MathParser:new()
6681

67-
-- Add a new variable with the name "x" and the value 5
82+
-- Add a variable and a function
6883
myParser:addVariable("x", 5)
69-
70-
-- Add a new function to the parser
7184
myParser:addFunction("double", function(a) return a * 2 end)
7285

73-
-- Solve a mathematical expression using the custom function
86+
-- Solve expressions using the custom function and variable
7487
print(myParser:solve("-double(x)")) -- Outputs: -10
7588

76-
-- Custom operators and precedence levels
77-
-- https://en.wikipedia.org/wiki/Operator_associativity
89+
-- Customize operator precedence levels and functions
7890
local CUSTOM_OPERATOR_PRECEDENCE_LEVELS = {
79-
-- The lower the precedence level, the lower the priority of the operator
8091
Unary = { ["-"] = 3 },
8192
Binary = { ["^"] = 2, ["+"] = 1, ["-"] = 1 },
82-
RightAssociativeBinaryOperators = {
83-
["^"] = true
84-
}
93+
RightAssociativeBinaryOperators = { ["^"] = true }
8594
}
8695

87-
-- The behavior of the operators can be customized
8896
local CUSTOM_OPERATOR_FUNCTIONS = {
8997
Unary = { ["-"] = function(a) return -a end },
9098
Binary = {
91-
-- Make the power operator behave like the XOR operator
9299
["^"] = function(a, b) return (a + b) % 2 end,
93-
94-
-- Make the addition operator behave like the subtraction operator, and vice versa
95100
["+"] = function(a, b) return a - b end,
96101
["-"] = function(a, b) return a + b end
97102
}
@@ -100,13 +105,29 @@ local CUSTOM_OPERATOR_FUNCTIONS = {
100105
myParser:setOperatorPrecedenceLevels(CUSTOM_OPERATOR_PRECEDENCE_LEVELS)
101106
myParser:setOperatorFunctions(CUSTOM_OPERATOR_FUNCTIONS)
102107

108+
-- Solve expressions using the custom operators
103109
print(myParser:solve("5 - 3")) -- Outputs: 8
104110
print(myParser:solve("5 + 3")) -- Outputs: 2
105111
print(myParser:solve("5 ^ 3")) -- Outputs: 0
106112
```
107113

108-
This is just a small sample of what MathParser.lua can do. For more information, check out the [documentation](docs/Documentation.md), the source of the [API](src/MathParser.lua), or the [example usage](./example.lua).
114+
For more details, refer to the [documentation](docs/Documentation.md), the [API source](src/MathParser.lua), or the [full example usage file](./example.lua).
115+
116+
## 🛣️ Roadmap
117+
118+
MathParser.lua is just getting started. Here are some of the enhancements and features we're planning for future releases:
119+
120+
- [ ] Introduce support for internal functions that can modify the evaluator's state at runtime. This includes setting variables and jumping to different parts of the expression.
121+
- [ ] Package MathParser.lua into a single file for easy distribution and usage. We also plan to make it available on LuaRocks and the project's GitHub releases.
122+
- [ ] Implement full support for Luau to cater to the Roblox developer community.
123+
- [ ] Expand the mathematical function library to include advanced functions not available in the standard Lua math library, such as factorial, permutations, and combinations.
124+
- [ ] Incorporate support for complex numbers to handle more sophisticated mathematical problems.
125+
- [ ] Optimize MathParser.lua further to enhance speed and reduce memory usage.
126+
- [ ] Develop optional support for parsing and solving equations and inequalities.
127+
- [ ] Add optional support for solving differential and integral equations.
128+
129+
We welcome feature requests and suggestions for improvements. Feel free to open an issue or a pull request. Your feedback is highly appreciated!
109130

110-
## License
131+
## 📜 License
111132

112133
MathParser.lua is (re)licensed under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)