-
Notifications
You must be signed in to change notification settings - Fork 0
Language Guide
Test User edited this page Mar 28, 2026
·
2 revisions
This document defines the currently supported KodPix syntax.
- Top-level functions
- Class blocks (entrypoint bridge through
Main.main)
Supported forms:
function int add(int a, int b) {
return a + b;
}
function main(a: int, b: int) -> int {
return a + b;
}
- Preferred:
type name - Compatibility:
name: type
-
int,float,string,boolean,char,void
- Variable declaration:
type name = expr; - Return:
return expr; - Branching:
if (...) { ... } else { ... } - Looping:
while (...) { ... },for (...; ...; ...) { ... }
- Arithmetic:
+ - * / % - Comparison:
== != < <= > >= === !== - Logical:
&& || ! - Increment:
i++,i--
Supported entry forms:
function int main() {
return 0;
}
class Main {
public void main() {
return;
}
}
- Semicolons are required.
- Conditions are intended to be boolean-strict.
Practical patterns for common KodPix tasks.
function int add(int a, int b) {
return a + b;
}
Runnable variant:
function int main() {
int a = 7;
int b = 5;
int sum = a + b;
return sum;
}
Quick run:
./scripts/run_kdx.sh examples/add_two_vars.kdxfunction int main() {
int i = 1;
i++;
i++;
return i;
}
function int main() {
int x = 0;
if (x == 0) {
return 0;
}
return 1;
}
function int main() {
int x = 0;
while (x < 3) {
x++;
}
return x;
}
class Main {
public void main() {
println("hello");
return;
}
}
footer