This document describes the language surface currently represented by the Vayu compiler, interpreter, VM, native compiler, runtime, and current tests/examples. It also records the command-line tooling and editor-facing features currently present in the repository. Backend-specific limitations are called out where relevant.
Official source extension: .vyu
For the latest roadmap and benchmark information, visit the official Vayu website.
Vayu source files use .vyu:
hello.vyu
main.vyu
control.vyu
fib.vyu
classes.vyu
Blocks are indentation-based and Python-inspired.
# This is a comment
name = "Vayu" # Inline comment
Type inference:
x = 5
y = 3.14
name = "Vayu"
flag = true
Explicit annotations:
x: int = 10
y: float = 2.5
name: str = "Vayu"
flag: bool = true
Current demonstrated types include int, float, bool, str, None, list<T>, map values, struct/class types, and function values. Integer-to-float promotion is supported where applicable.
name = "Vayu"
message = "Hello, " + name
print(message)
print("value:", 42)
print(str(42))
Current string functionality also demonstrates strip(), lower(), upper(), split(), join(), replace(), find(), contains(), starts_with(), ends_with(), is_digit(), is_alpha(), is_space(), and char_at().
def add(a: int, b: int) -> int:
return a + b
print(add(2, 3))
Typed parameters, return types, None returns, bare return, and recursion are supported.
def fib(n: int) -> int:
if n < 2:
return n
return fib(n - 1) + fib(n - 2)
if x < 0:
print("negative")
elif x == 0:
print("zero")
elif x < 10:
print("small")
else:
print("big")
while and for loops are supported:
i = 5
while i > 0:
print(i)
i = i - 1
for color in ["red", "green", "blue"]:
print(color)
range() supports one, two, and three arguments:
range(5)
range(2, 8)
range(0, 10, 2)
Nested loops, break, and continue are supported.
| Operator | Meaning |
|---|---|
+ |
addition |
- |
subtraction / unary negative |
* |
multiplication |
/ |
division |
// |
floor/integer division |
% |
modulo |
** |
exponentiation |
Example:
print(1 + 2)
print(10 - 3)
print(4 * 5)
print(7 / 2)
print(7 // 2)
print(7 % 3)
print(2 ** 10)
print(-5)
print(- -5)
Exponentiation is right-associative:
print(2 ** 3 ** 2)
Output:
512
Equivalent to 2 ** (3 ** 2).
Comparison operators:
== != < <= > >=
Logical operators:
and or not
Examples:
print(2 < 3)
print(1 == 1)
print(true and false)
print(true or false)
print(not true)
Parentheses control evaluation order:
print(1 + 2 * 3) # 7
print((1 + 2) * 3) # 9
Exponentiation is evaluated right-to-left, while normal arithmetic, comparison, and logical precedence applies to the currently implemented operators.
nums = [1, 2, 3, 4, 5]
The current implementation demonstrates:
- zero-based indexing
- negative indexing
- element assignment
len()append()pop()insert()contains()in- concatenation with
+ - repetition with
* - nested lists
- iteration
nums[0] = 100
nums.append(6)
last = nums.pop()
nums.insert(0, 50)
print(nums[-1])
print(3 in nums)
print(len(nums))
List slicing is implemented. Python-style slicing is currently supported for lists, tuples, and strings across the parser, AST/type-checking, VM/runtime, and native code-generation paths.
ages = {
"alice": 30,
"bob": 25
}
print(ages["alice"])
ages["carol"] = 40
ages.put("dave", 22)
ages.remove("bob")
print("alice" in ages)
print(ages.keys())
print(len(ages))
Map indexing, assignment, put(), remove(), contains(), keys(), len(), membership, and iteration over keys are demonstrated by the current implementation.
Tuples and sets are now first-class collection types.
Tuples support creation/conversion, indexing, iteration, stringification, slicing, and concatenation. Sets support creation/conversion, iteration, stringification, and set operations such as add(), remove(), and union().
a = (1, 2, 3)
b = (4, 5)
c = a + b
s = set([1, 2, 3])
s.add(4)
Structs provide named fields:
struct Player:
name: str
score: int
p = Player("NotY", 100)
print(p.name)
p.score = 200
Positional and keyword construction, field access/modification, and nested structs are demonstrated.
Classes support fields, __init__, self, methods, inheritance, overriding, and super().
class Player:
def __init__(self, name: str):
self.name = name
def greet(self) -> None:
print("Hello, " + self.name)
p = Player("Vayu")
p.greet()
Inheritance and multi-level inheritance are demonstrated by the current examples.
The current implementation demonstrates function values, lambdas, closures, higher-order calls, and:
map()
filter()
reduce()
sorted()
any()
all()
sum()
Vayu supports try, except, finally, and raise:
try:
x = 10 / 0
except ZeroDivisionError as e:
print(e.message)
finally:
print("done")
The current implementation demonstrates Exception, RuntimeError, TypeError, ValueError, and ZeroDivisionError, plus exception variables, multiple handlers, bare except, nested exceptions, re-raising, raising another exception, and raising a string.
import math_helpers
import math_helpers as math
from math_helpers import helper
from math_helpers import helper as h
Module constants, functions, structs, aliases, and chained member access are demonstrated. Modules use .vyu files.
Current math functionality includes:
sqrt()
floor()
ceil()
sin()
cos()
exp()
log()
log10()
log2()
pi
e
abs()
Expression statements, attribute chains, and indexing are supported:
player.stats.score
items[0]
grid[0][1]
Vayu includes a type-checking stage for explicit annotations and supported type relationships.
x: int = "hello"
This is invalid because a string cannot be assigned to an int.
The compiler can generate/dump an AST representation for supported programs. The AST is used as a structured representation between parsing and later compiler stages.
Arithmetic has been exercised with:
print(1 + 2)
print(10 - 3)
print(4 * 5)
print(7 / 2)
print(7 // 2)
print(7 % 3)
print(2 ** 10)
print(-5)
print(- -5)
print(1 + 2 * 3)
print((1 + 2) * 3)
print(2 ** 3 ** 2)
The demonstrated results include 3, 7, 20, 3.5, 3, 1, 1024, -5, 5, 7, 9, and 512.
Control-flow verification includes if/elif/else, while, for over ranges and lists, nested loops, break, continue, and loop-based accumulation.
total = 0
for n in range(1, 11):
total = total + n
print("sum 1..10 =", total)
Output:
sum 1..10 = 55
The reference documents implemented or demonstrated behavior only. Current areas include variables, types, functions, recursion, conditions, loops, arithmetic, comparisons, logical expressions, collections, structs, classes, inheritance, lambdas/closures, exceptions, modules, math functionality, type checking, AST generation, and VM-oriented execution.
Known limitations remain documented until the corresponding compiler features are implemented and tested. Some syntax is accepted through parser-level handling while its backend/runtime support can still be more limited than the frontend syntax suggests.
The official Vayu source extension is .vyu.
This section organizes the current language surface by category so the syntax reference can be used as a quick lookup.
.vyusource files- indentation-based blocks
- spaces and tabs for indentation
#comments- blank lines
- newline / indent / dedent structural tokens
- single-quoted and double-quoted strings
- character literals
- decimal, binary, octal, hexadecimal, and exponent-form numeric literals
true/false/noneplusTrue/False/None
def name(...):
struct Name:
class Name:
const NAME = value
enum Name:
extern "C":
name = value
name: Type = value
name += value
name -= value
name *= value
name /= value
name %= value
name **= value
name //= value
name &= value
name |= value
name ^= value
name <<= value
name >>= value
if condition:
elif condition:
else:
while condition:
for item in iterable:
break
continue
pass
def name(a: Type, b: Type) -> ReturnType:
...
return value
return
Function values, lambdas, closures, recursion, higher-order calls, and generic/type-parameter metadata are part of the current compiler architecture.
literal
identifier
(a + b)
object.member
object[index]
object[start:end]
call(arg)
lambda x: expression
[1, 2, 3]
{"name": "Vayu"}
(1, 2, 3)
set([1, 2, 3])
Supported collection families include list, map, tuple, set, and string operations, with indexing and slicing where implemented.
Arithmetic:
+ - * / // % **
Comparison:
== != < > <= >=
Logic and membership:
and or not in is
Bitwise:
& | ^ ~ << >>
Compound assignment:
+= -= *= /= %= **= //= &= |= ^= <<= >>=
Unary/native-oriented:
+x -x not x ~x &x *x
class Child(Parent):
field: Type
def __init__(self, value: Type):
self.field = value
def method(self) -> None:
...
Supported class-related concepts include inheritance, overriding, constructors, methods, self, super, static members, and visibility metadata.
try:
...
except ExceptionType as e:
...
finally:
...
raise ExceptionType("message")
import module
import module as alias
from module import name
from module import name as alias
def values():
yield value
Generator support includes suspension, resume, next, completion, and exception propagation in the VM implementation.
ptr<Type>
ref<Type>
unique<Type>
shared<Type>
weak<Type>
&value
*pointer
malloc(...)
free(...)
Native FFI also provides an extern C declaration path and native function-pointer/library integration.
The language/runtime exposes Vayu-native utility families for reflection, numeric helpers, iteration, collections, functional operations, filesystem/OS work, networking, crypto, randomness, regular expressions, threading, time, and JSON, subject to execution-route coverage. Python-inspired syntax does not imply Python runtime or package compatibility.
IntLit FloatLit StringLit CharLit BoolLit NoneLit
NameRef Unary Binary Grouping Call Attr Index
ListLit MapLit Lambda GenericType TupleLit SetLit Slice
Expr Assign AnnotAssign If While Def Return
Struct Class For Try Raise Import FromImport
Pass Break Continue Const Enum Yield Block Extern
The parser also contains dedicated paths for match, with, unsafe handling, namespace handling, visibility modifiers, and compound assignment.
Hard-reserved words currently include:
def return if elif else while for break continue pass
class struct enum interface new delete import from as
try except finally with raise unsafe spawn wait task async await
and or not in is lambda yield true false none
True False None int float bool str char bytes
ptr ref unique shared weak const extern
Words such as match, case, defer, namespace, static, public, protected, and private are handled through parser-level logic rather than being reserved by the lexer in the same way.
vayuc file.vyu
vayuc file.vyu --vm
vayuc file.vyu --native # VIB native code generation not implemented yet
vayuc file.vyu --native-out output.exe
vayuc file.vyu --check
vayuc file.vyu --dump-tokens
vayuc file.vyu --dump-ast
vayuc file.vyu --dump-bytecode
vayuc file.vyu --dump-ir
vayuc file.vyu --bench 10
vayuc --emit-runtime runtime.c # currently unavailable
Debugging flags also include --no-check and --no-opt.
The current project contains tree-walking and bytecode/VM execution paths. Native-oriented language features exist in the frontend/runtime, but the new VIB native code generator is not implemented yet.
VIB (Vayu Integration Backend) is the integrated toolchain system being built inside this repository. See VIB architecture and the engineering roadmap.
The current repository also contains dedicated tooling around the language:
vayuc Vayu compiler
vls Vayu Language Server
vfmt Vayu formatter
vlint Vayu linter
The official VS Code extension integrates .vyu files with the language server and exposes editor-side language features including syntax highlighting, diagnostics, hover, completion, go-to-definition, references, rename, signature help, formatting, and linting.
VS Code extension: https://marketplace.visualstudio.com/items?itemName=NotY215.vayu-Official
Direct VS Code installation URI: vscode:extension/NotY215.vayu-Official
The current compiler command-line modes include:
vayuc file.vyu
vayuc file.vyu --vm
vayuc file.vyu --native
vayuc file.vyu --native-out output.exe
vayuc file.vyu --check
vayuc file.vyu --dump-tokens
vayuc file.vyu --dump-ast
vayuc file.vyu --dump-bytecode
vayuc file.vyu --dump-ir
vayuc file.vyu --bench [N]
Current compiler flags also include:
--no-check
--no-opt
Native optimization controls and runtime export will be documented when VIB implements them.
--no-opt disables the VM bytecode optimizer. Native optimization levels will be documented when VIB code generation implements them.
The target architecture routes Vayu source through the existing frontend into a Vayu-owned verified IR (VIR), then into interpreter, VM, or VIB native execution. VIR and native code generation remain planned work. The old external-backend invocation path has been removed from the active native compiler; --native currently reports that VIB code generation is not implemented.
For architecture and roadmap information, see VIB and Roadmap.md.
The native compiler exposes a raster module for framebuffer and 3D rendering work. Raster functionality is native-only and integrates with the existing gui canvas/window layer.
import raster
fb: int = raster.fb_new(640, 480)
raster.fb_enable_depth(fb)
raster.fb_clear(fb, 0xFF101018)
raster.fb_clear_depth(fb)
raster.fb_present(fb, canvas, 0, 0)
raster.fb_free(fb)
Framebuffer operations include creation/freeing, depth enable/disable/clear, clear, pixel access, and presentation.
Matrices use the Q16.16 fixed-point convention:
m: int = raster.mat_new()
raster.mat_identity(m)
raster.mat_translate(m, x, y, z)
raster.mat_rotate_x(m, degrees)
raster.mat_rotate_y(m, degrees)
raster.mat_rotate_z(m, degrees)
raster.mat_perspective(m, fov, aspect, near, far)
raster.mat_look_at(m, ex, ey, ez, tx, ty, tz, ux, uy, uz)
raster.mat_mul(dst, a, b)
raster.mat_free(m)
mesh: int = raster.mesh_new()
raster.mesh_add_vert(mesh, x, y, z, u, v)
raster.mesh_add_vert_lit(mesh, x, y, z, nx, ny, nz, u, v)
raster.mesh_set_normal(mesh, index, nx, ny, nz)
raster.mesh_add_tri(mesh, i0, i1, i2)
raster.mesh_clear(mesh)
raster.mesh_free(mesh)
Meshes support dynamic vertices, normals, UVs and triangle indices.
tex: int = raster.tex_new(64, 64)
raster.tex_set(tex, x, y, 0xFFFFFFFF)
raster.tex_set_filter(tex, 2)
raster.tex_gen_mipmaps(tex)
width: int = raster.tex_width(tex)
height: int = raster.tex_height(tex)
raster.tex_free(tex)
The native texture path supports nearest, bilinear and trilinear filtering, mipmap generation and LOD selection. A framebuffer can be converted to a texture with tex_from_fb, and a texture can be presented to a GUI canvas with tex_present.
raster.set_ambient(0xFF202020)
raster.light_clear()
raster.light_set(0, kind, x, y, z, color, intensity)
raster.draw_mesh(fb, mesh, mvp, tex, 0xFFFFFFFF)
raster.draw_mesh_lit(fb, mesh, mvp, model, tex, shade_mode, tint,
eye_x, eye_y, eye_z)
The rasterizer provides perspective-correct textured triangles, depth testing, ambient/directional lighting, per-vertex normals, Gouraud/Phong-style lighting and specular support.
raster.post_gamma(tex, gamma)
raster.post_invert(tex)
raster.post_tint(tex, color)
raster.post_brightness(tex, delta)
raster.post_threshold(tex, threshold)
These effects operate in-place on the level-0 texture.
Raster output is displayed through the native GUI canvas:
c: int = gui.canvas_from_window()
raster.fb_present(fb, c, 0, 0)
gui.canvas_free(c)
Current examples include raster_tri.vyu, raster_cube.vyu, raster_lit_cube.vyu, and raster_postfx.vyu.
Raster matrix, position, normal, UV and lighting values use the native Q16.16/fixed-point conventions. Colors use packed ARGB-style integers. Native resource APIs perform bounds and handle validation.
The language frontend, interpreter, VM, and native execution are separate capability routes. The VIB native route is currently under implementation and must regain support feature-by-feature through shared conformance tests. GUI, raster, FFI, pointer, and other native capabilities must not be described as supported on a target until the corresponding VIB implementation and tests are present. Python, Java, .NET, and other foreign-language runtime compatibility is not currently supported.