@@ -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
5788add_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
6395To run tests:
0 commit comments