Zspie is a fast, easy, dynamic programming language for beginners. It has all the basic features most languages provide: expressions, variables, scopes, string, globals, if-else, for-loop, while-loop, functions. The compiler is written entirely in C which makes it really fast.
The project uses Cmake as it's build system.
- A C compiler
- Git
- Cmake
- Platform specific build tools
- Make (linux)
- MS Visual Studio (windows)
- XCode (OSX)
- Clone the repo and cd into the project root directory.
git clone https://github.com/prashantrahul141/zspie && cd zspie
- Run cmake to create build files for your platform.
cmake
additionally you can provide -DCMAKE_BUILD_TYPE={configuration}
to build in Debug
, Release
configurations.
- Open/run your platform specific build files.
- For Linux: just run make
make
-
For windows: Open Microsoft Visual Studio Solution file.
-
For OSX: Open XCode Solution file.
You can either use the live repl
zspie
or pass a .zspie
file
zspie main.zspie
Zspie supports text files with zspie
file extension.
example: main.zspie
A simple hello world program in Zspie:
print "Hello, World!";
Semi-colons at the end of every line is mandatory in Zspie.
Zspie has following datatypes
These can number literals which can be both integers and floating point numbers.
examples: 1
, 2.5
, 9
These are string literals defined inside "
examples: "Zspie"
, "Strings are easy"
These are boolean literals which can be either true
or false
.
Zspie has nulls, It can be defined using the null
keyword. All uninitialized variables are given the value of null
.
Zspie has following operators:
=
- equals
-
- Unary negation
and
- logical AND
or
- logical OR
!
- logical NOT
+
- sum
-
- difference
*
- product
/
- division
==
- is equals
!=
- is not equals
>
- is less than
>=
- is less than or equals
>
- is greater than
>=
- is greater than or equals
Zspie has only one type of comment, single line comments, which can be defined using //
at the beginning of a line.
// This is a comment.
// The Lexer completely ignores any line starting with //
// The Whole line is ignored.
Zspie has variables which can be defined using the let
keyword without defining any data type, zspie can automatically detect datatype at runtime.
let a; // default value is null if nothing is assigned.
let b = 2; // numbers: both integers
let c = 2.5; // and floats
let d = "Strings are easy"; // strings
let e = true; // booleans
Zspie variables have scope like any other modern programming language.
let a = 1;
{
let a = 2;
print a; // 2
}
print a; // 1
Zspie has if
else
conditionals. It can be defined using the following syntax:
let a = 1;
if (a == 1) {
print "A is infact 1";
} else {
print "A is not 1";
}
while loops in zspie can be defined using the following syntax:
let a = 10;
while (a > 1) {
print a;
a = a - 1;
}
Zspie has support forfor
loops (even though it is just syntatic sugar).
for(let i = 0; i < 10; i = i + 1) {
print i;
}
Zspie have user defined functions, and ability to call them.
A function in zspie can be defined using the following syntax:
fn greet(name) {
print "Hello " + name;
}
A function can be called using the following syntax:
greet("Zspie");