Giter VIP home page Giter VIP logo

wolke-lang's Introduction

Wolke Language

wlk2


☁️ Description ☁️

Wolke is a statically typed, imperative language based on Python language.

There are 3 supported types: Int, String, Boolean.

Language makes such concepts as variable shadowing, static typing and static binding possible.


💡 Syntax 💡

Assignment

Int x = 5
Boolean y = False
String z = "a"

Print and assert

print(x)
print("Hello!")
assert(s == "local")
assert(x > 2)

Conditional statements

if x == 5:
    res = True
else:
    res = False

Loops and flow control statements

while x > 0:
    if x == 100:
        break
    if x == 200:
        continue
    x = x - 1

Functions

def increment(x | Int) -> Int:
    return x + 1

Pass variable by reference

def increment(y | Int&) -> Void:
    y = y + 1

Comments

# single line comment
/*
    multi
    line
    comment
*/

▶️ Usage ▶️

To run the interpreter, type these commands into terminal:

make
./interpreter <path_to_file>.wlk

📃 Implementation 📃

Wolke interpreter goes through 3 stages:

  1. Syntax checking

  2. Static type checking

  3. Program interpretation and evaluation


✨ Examples ✨

def multiply_str(s | String&, x | Int) -> Void:
    String tmp = s

    while x > 1:
        s = s + tmp
        x = x - 1


def main() -> Void:
    String s = "aa"

    multiply_str(s, 3)
    print(s)
    assert(s == "aaaaaa")

More examples of both corrent and incorrect programs are located here.


🧱 File structure 🧱

Directory Description
examples/bad programs resulting in an error
examples/good programs executing correctly
grammar/ files containing grammar of Wolke language
src/Gen source files generated by bnfc (docs)
src/ source files

wolke-lang's People

Contributors

drknzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

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