This programing language has been created for the Object oriented programing class
This project is written in ISO C++ 17 compliant C++.
To download compiled binary files for windows and linux go to:
https://github.com/mateuszkojro/programing-language/releases
and look for the assets tab. Pdf source documentaton can be found in the same places
To download source:
git clone --recursive https://github.com/mateuszkojro/programing-language
or go to:
https://github.com/mateuszkojro/programing-language/releases and find the
Source code packed in zip
ot tar.gz
archives in Assets section
Project is based on CMake
and needs a C++ compiler compatible with ISO C++ 17 standard so the steps are standard:
cd ./programing-language
cmake -B build
make -C build/
On Windows
./build/interpreter.exe
and on Linux:
./build/interpreter
Program runtime can be extended using arbitrary script:
On Windows
./build/interpreter.exe -l <path-dto-script>
and on Linux:
./build/interpreter -l <path-to-script>
On Windows
./build/interpreter.exe <script-path>
and on Linux:
./build/interpreter <script-path>
WARNING! Tests are not compiled when using code blocks make file
Tests are written using Catch2 testing framework and can be run after compiling by typing:
On linux:
./build/language/tests
and on Windows
./build/language/tests.exe
You should be greated with simple interactive prompt:
=== Unnamed programing languge ===
Compiled with MSVC 1929.0.0 on Sep 17 2021 23:29:44
=>
All expression can be run inside interactive shell
For example:
=> 2+2
4
=> 3*2
6
=> 12 / 3
4
Operator | Performed operatrion | Return value |
---|---|---|
* |
Floating point multiplication | float |
/ |
Floating point division | float |
+ |
Floating point addition | float |
- |
Floating point subtraction | float |
% |
Integer modulus | int |
// |
Integer division | int |
== |
Equality comparassion | 0 or 1 |
!- |
Inequality comparassion | 0 or 1 |
> |
More than | 0 or 1 |
< |
Less than | 0 or 1 |
You can bind variable using mat
keyword:
=> mat x = 12
12
=> mat x= null
null
=>mat x
nan
as you can see variable assigments return value that is currently being assigned
You can use variables in math equations
=> x
12
=> x + 12
24
=> x = x * 3
36
=> x
36
Scopes are defined using {}
and are commonly used in other langugae constructs they always evaluate to the last contained expression. For example:
=> {}
Null
=> {12}
12
=> {12 2}
2
Values from outer scope are present and mutable in inner scope:
=> mat x = 12
12
=> { mat z = 20 x=20 x }
20
=> x
20
but reverse statment is not true
=> { mat x = 7 }
7
=> x
Null
In this language everything that is not floating point NaN
, Null
or 0
is True
if
statments:
=> if (1) {10}
10
=> if (0) {10}
Null
=> mat x = 1
1
=> if (13) {27}
27
=> if (x) {13}
13
if() {} else {}
statments
=> if (1) {12} else {10}
12
=> if (0) {1} else {10}
10
=> if (1) { do_sth() }
# do_sth() result
=> if (check_prime(n)) { ... } else { ... }
If statments can be to assign values to variables, then the value assigned will be the last value in evaluated block or Null if the block does not exist
=> mat x = 1
1
=> x = if (x) {20} else {11}
20
=> x
20
While loops will execute statments in coresponding block as long as
condition is True
=> while (i) { ... i=i-1 i }
0
While loops also return value (Evaluation of the last statment in the block on the last evaluation of the block)
=> mat x = 0
0
=> mat sum = 0
0
=> mat i = 10
10
=> x = while (i) { sum =sum+i i=i-1 sum }
12
Functions can be defined using fn
keyword:
=> fn two () {2}
Null
and called using ()
after function name:
=> two ()
2
Functions can have arguments separated by whitespace
=> fn add (a b) {mat x = a+b x}
Null
then while calling arguments need to be added that will be passed to function
=> add(2 12)
14
Additional scripts can be loaded into runtime using @load <path-without-spaces>
call
For example to load stdlib.script
:
=> @load stdlib.script
=> PI
3.1415926
Where PI is defined inside stdlib.script
- Refernece counting garbage collector
- Builtin funtcions support - support for functions defined in C++
- Changing main datatype from
Scalar
toMatrix
- Oreder of operations in math equations
- Bug fixes