Documentation home / Language
GSVE Language Reference
Complete reference to GSVE syntax, values, operators, control flow, functions, imports, iteration, nested data and class-like objects.
Language design
GSVE is the source language executed by greenServeFE. Programs use the .gsve extension. The VM language keeps a compact syntax with explicit definitions, blocks, functions and module imports.
Keywords
define if else for in while func return break continue import from true false null
Values
Supported runtime values include null, numbers, booleans, strings, arrays, objects, functions, native functions and iterators.
define title = "greenServeFE";
define ready = true;
define scores = [90, 95, 100];
define profile = {name: "Ada", active: true};Operators
Arithmetic: + - * / %. Comparisons: == != < <= > >=. Logical: && || !. Logical AND and OR short-circuit and return booleans.
Control flow
if (ready) {
print("ready");
} else {
print("waiting");
}
define i = 0;
while (i < 3) {
print(i);
i = i + 1;
}
for (item in scores) {
print(item);
}Functions, recursion and closures
func factorial(n) {
if (n <= 1) { return 1; }
return n * factorial(n - 1);
}
print(factorial(5));Function values capture their lexical environment. The VM supports recursion and nested functions.
Iteration semantics
- Arrays yield their values.
- Strings yield one-character strings.
- Objects yield their keys in insertion order.
Nested data and mutation
define account = {profile: {name: "Ada", scores: [10, 20, 30]}};
account.profile.name = "Grace";
account.profile.scores[1] = 99;Class-like objects
class(fields, methods, parent?) creates a class descriptor; new(ClassName) creates an instance; instanceof(instance, ClassName) checks the class and parent chain. Methods are ordinary functions and receive self explicitly. This is not automatic receiver binding or constructor dispatch.
define Person = class({name: "unknown"}, {
greet: func(self) { return "Hello " + self.name; }
});
define ada = new(Person);
ada.name = "Ada";
print(ada.greet(ada));Imports
import gs_math; from gsnum import sum, mean; print(gs_math.sqrt(81));
