Skip to content

Commit e3d784d

Browse files
authored
Update README.md
1 parent 757b27f commit e3d784d

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

README.md

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,58 @@ int main() {
3838
}
3939
```
4040

41+
## Extending Functionality
42+
43+
### Adding Custom Function or Operator
44+
```cpp
45+
// Register logarithmic function
46+
parser.registerOperator("log", parser::Operator{
47+
parser::Operator::Type::FUNCTION,
48+
4, // Precedence
49+
false, // Right associativity
50+
1, // Single argument
51+
[](auto args) { return std::log(args[0]); },
52+
"log" // Function name
53+
});
54+
```
55+
56+
### Adding Constant
57+
```cpp
58+
// Register tau constant (2pi)
59+
parser.registerConstant("tau", 6.28318);
60+
```
61+
4162
## Installation
4263

43-
1. Clone the repository:
44-
```bash
45-
git clone https://github.com/yourusername/math-parser.git
64+
### Method 1: FetchContent (Recommended for CMake Projects)
65+
66+
Add to your CMakeLists.txt:
67+
```cmake
68+
include(FetchContent)
69+
FetchContent_Declare(
70+
math_parser
71+
GIT_REPOSITORY https://github.com/H5JKey/math-parser.git
72+
GIT_TAG main
73+
)
74+
FetchContent_MakeAvailable(math_parser)
75+
76+
target_link_libraries(your_target math_parser_lib)
4677
```
4778

48-
2. Build with CMake:
79+
### Method 2: Manual Inclusion
80+
81+
1. Clone repository:
4982
```bash
50-
mkdir build && cd build
51-
cmake ..
52-
make
83+
git clone https://github.com/H5JKey/math-parser.git
5384
```
5485

55-
3. Link to your project:
86+
2. Add to your project:
5687
```cmake
5788
add_subdirectory(path/to/math-parser)
58-
target_link_libraries(your_target mathparser)
89+
target_link_libraries(your_target math_parser_lib)
5990
```
6091

92+
6193
## Testing
6294

6395
To run tests:

0 commit comments

Comments
 (0)