peach π
Lightweight dependency-free scripting language with C++17, that can be extended by user. All scripts can be evaluated in your program runtime.
Documentation
Wiki is avaiable on github: syntax page
Current features
-
Command line interpreter
-
File interpreter
-
Single variable type -
std::int32_t
-
if/else
conditions -
while
loops -
Division into blocks with indentation
-
Variable declaration with
let
keyword -
Arithmetical, logical operators and corresponding assignation operators (
a += 1
is simillar toa = a + 1
) -
Informative error messages
Building
- Make sure following commands works fine on your machine:
git --version
cmake --version
clang-10 --version
- Build project by typing in your command line:
mkdir build && cd build
cmake ..
make
- Executable file can be found in
/build/peach
if build was successfull
How to use
Using with command line interface
- Simply run
/build/peach
, you will get:
gleb@ZenBook:~/Documents/projects/peach$ ./build/peach
Peach
>>> let even_numbers = 0
0
>>> let n = 11
11
>>> while n -= 1
... even_numbers += n % 2 == 0
...
5
>>>
- And youβre good to go
Write script
- Simply run
/build/peach <filename>
, where<filename>
contains program code, for example, if this ishello.pch
let a = 123
let cnt_even = 0
let cnt_odd = 0
let some_other_variable
while (a != 0) & cnt_even < 10
if a % 2 == 0
cnt_even += 1
if cnt_even % 3 == 2:
some_other_variable += 2 ** cnt_even
else
cnt_odd += 1
a -= 1
some_other_variable
Then you program evaluation will look like:
gleb@ZenBook:~/Documents/projects/peach$ ./build/peach hello.pch
292