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.
Int x = 5
Boolean y = False
String z = "a"
print(x)
print("Hello!")
assert(s == "local")
assert(x > 2)
if x == 5:
res = True
else:
res = False
while x > 0:
if x == 100:
break
if x == 200:
continue
x = x - 1
def increment(x | Int) -> Int:
return x + 1
def increment(y | Int&) -> Void:
y = y + 1
# single line comment
/*
multi
line
comment
*/
To run the interpreter, type these commands into terminal:
make
./interpreter <path_to_file>.wlk
Wolke interpreter goes through 3 stages:
-
Syntax checking
-
Static type checking
-
Program interpretation and evaluation
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.
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 |