-
Notifications
You must be signed in to change notification settings - Fork 72
Download and Setup
- Clone or download it from the official github repo into your project's folder:
git clone https://github.com/cparse/cparse.git cparse- Compile it using
make:
$ cd cparse
$ make releaseThis will create the core-shunting-yard.o and builtin-features.o binaries.
- Write your code including the shunting-yard header file:
// your_code.cpp
#include <iostream>
#include "./shunting-yard.h"
int main() {
std::cout << calculator::calculate("'Hello ' + 'World'") << std::endl;
}- Compile your project including these 2 binaries and its headers:
$ g++ -I./cparse your_code.cpp cparse/{core-shunting-yard.o,builtin-features.o}If you want to modify existing built-in functions and operations please see the topic:
Note: VS 2017 or later is required for
C++11support.
- Clone or download it from the official github repo into your project's folder:
git clone https://github.com/cparse/cparse.git cparse-
Include the
cparsedirectory to your project's path -
Include the core files into your project:
cparse/shunting-yard.cppcparse/packToken.cppcparse/functions.cppcparse/containers.cpp
- Write your code including the shunting-yard header file and the optional
builtin-features.incfile:
// your_code.cpp
#include <iostream>
#include "./cparse/shunting-yard.h"
#include "./cparse/builtin-features.inc"
int main() {
// Initialize it only once:
cparse_startup();
std::cout << calculator::calculate("'Hello ' + 'World'") << std::endl;
}- Compile and run your project. The output "Hello World" should appear on the console.
Please note that this is an advanced option: If you just want to add new functions and operations alongside the built-in ones this is not required for you. This topic is required only if you want to erase/replace/modify existing functionalities to make sure your programming language has only the functions you want in it.
To make it possible to modify the existing built-in features, their code is kept separate. So to modify it you just need to make a copy of it and use it instead or explaining in more details:
- You should not include the
cparse/builtin-features.incfile or thecparse/builtin-features.obinary. - You should copy the directory
cparse/builtin-features/and the filecparse/builtin-features.incto your project - Then edit your copy of the
builtin-features.incto include the files from your copy of thebuiltin-features/directory.
And that's it.
Now you can safely edit any of the files in your copy of the directory builtin-features/ and instead of including the cparse/builtin-features.o binary file or including the cparse/builtin-features.inc file you
should just make use of your own copies of them.
Note: In the case of the
builtin-features.ofile you should also make a copy of thecparse/builtin-features.cppfile and change it to use your copy ofbuiltin-features.inc, then compile it into the.oversion using thegcc -coption.