Skip to content

drknzz/wolke-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published