Giter Club home page Giter Club logo

zspie's Introduction

Zspie Lang

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.

Building

The project uses Cmake as it's build system.

Requirements:

  1. Clone the repo and cd into the project root directory.
git clone https://github.com/prashantrahul141/zspie && cd zspie
  1. Run cmake to create build files for your platform.
cmake

additionally you can provide -DCMAKE_BUILD_TYPE={configuration} to build in Debug, Release configurations.

  1. 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.

Using the compiler

You can either use the live repl

zspie

or pass a .zspie file

zspie main.zspie

Language documentation

File Extension

Zspie supports text files with zspie file extension. example: main.zspie

Hello, world!

A simple hello world program in Zspie:

print "Hello, World!";

Semi-colons at the end of every line is mandatory in Zspie.

Datatypes

Zspie has following datatypes

Numbers

These can number literals which can be both integers and floating point numbers.

examples: 1, 2.5, 9

Strings

These are string literals defined inside "

examples: "Zspie", "Strings are easy"

Booleans

These are boolean literals which can be either true or false.

Null

Zspie has nulls, It can be defined using the null keyword. All uninitialized variables are given the value of null.

Operators.

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

Comments

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.

Variables

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

Scope

Zspie variables have scope like any other modern programming language.

let a = 1;
{
    let a = 2;
    print a; // 2
}
print a; // 1

Conditionals

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 loop

while loops in zspie can be defined using the following syntax:

let a = 10;
while (a > 1) {
    print a;
    a = a - 1;
}

For loops

Zspie has support forfor loops (even though it is just syntatic sugar).

for(let i = 0; i < 10; i = i + 1) {
    print i;
}

Functions

Zspie have user defined functions, and ability to call them.

Function declaration

A function in zspie can be defined using the following syntax:

fn greet(name) {
    print "Hello " + name;
}

Calling functions

A function can be called using the following syntax:

greet("Zspie");

zspie's People

Contributors

prashantrahul141 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.