Hello world
A minimal .gsve program using the built-in print function.
print("Hello, greenServeFE");Open .gsve sourceCanonical sourceMACORAONE / DEVELOPER DOCUMENTATION
Executable .gsve examples for values, arrays, objects, functions, closures, native imports, and the VM server interface.
A minimal .gsve program using the built-in print function.
print("Hello, greenServeFE");Open .gsve sourceCanonical sourceVariables, arithmetic operators, and numeric values.
define a = 20;
define b = 6;
print(a + b);
print(a - b);
print(a * b);
print(a / b);
print(a % b);Open .gsve sourceCanonical sourceArray indexing, assignment and for/in iteration.
define values = [10, 20, 30, 40];
print(values[0]);
values[1] = 25;
print(values);
for (value in values) {
print(value);
}Open .gsve sourceCanonical sourceObject literals, named properties and property updates.
define user = {
name: "Alex",
role: "developer",
active: true
};
print(user.name);
user.active = false;
print(user.active);Open .gsve sourceCanonical sourceFunction code objects run in their own VM frames.
func add(a, b) {
return a + b;
}
print(add(4, 5));Open .gsve sourceCanonical sourceThe VM supports captured lexical environments and closures.
func make_adder(base) {
func add(value) {
return base + value;
}
return add;
}
define add10 = make_adder(10);
print(add10(5));
print(add10(20));Open .gsve sourceCanonical sourceRequires the native gsnum shared library to be installed and discoverable.
import gsnum;
print(gsnum.sum(1, 2, 3, 4));
print(gsnum.mean([10, 20, 30]));
print(gsnum.sqrt(144));Open .gsve sourceCanonical sourceDemonstrates the current VM server module interface.
import server;
func home(req, res) {
res.send("Hello from greenServeFE");
}
server.get("/", home);
server.serve(".", 8080, {
index: "index.html",
static: true
});Open .gsve sourceCanonical sourceStore values in an array and process each element with a loop.
define scores = [82, 95, 74, 88];
define total = 0;
for score in scores {
total = total + score;
}
print(total);
print(len(scores));Open version 1.0.3 sourceCanonical sourceRepresent structured application data with object properties.
define user = {
name: "Ada",
role: "developer",
active: true
};
print(user.name);
print(user.role);
print(user.active);Open version 1.0.3 sourceCanonical sourceUse branches to choose behavior based on a value.
define temperature = 28;
if temperature >= 30 {
print("Hot");
} else {
print("Comfortable");
}Open version 1.0.3 sourceCanonical sourceExplore the VM server interface and API-oriented route patterns. Networking support depends on the runtime build.
import server;
func health(req, res) {
res.send("greenServeFE 1.0.3 is running");
}
server.get("/health", health);Open version 1.0.3 sourceCanonical sourcemake clean all
./greenServeFE docs/examples/01-hello.gsve
./greenServeFE --dump docs/examples/03-arithmetic.gsve
./greenServeFE --trace docs/examples/15-functions.gsveFor native imports, install the matching module and ensure GREENSERVE_MODULE_PATH points to its shared-library directory. External HTTP/database/crypto dependencies and network access may be required for those module examples.