Statements
if, while, do, for
Section titled “if, while, do, for”These work as in C, with the truthiness rules of operators. break leaves the nearest loop or switch. continue goes to the next turn of the nearest loop. There is no goto, and no break 2.
function onCreated() { temp.total = 0; for (temp.i = 1; temp.i <= 4; temp.i++) { if (temp.i == 3) { continue; } temp.total += temp.i; } echo(temp.total); // expect: 7}Run this example in the playground
Labels
Section titled “Labels”A loop or a switch can carry a label. break label; and continue label; then leave or continue that statement from inside an inner one. A label in front of anything else is a compile error.
function onCreated() { temp.found = 0; outer: for (temp.a = 1; temp.a <= 3; temp.a++) { for (temp.b = 1; temp.b <= 3; temp.b++) { if (temp.a * temp.b == 4) { temp.found = temp.a @ "x" @ temp.b; break outer; } } } echo(temp.found); // expect: 2x2}Run this example in the playground
For-each
Section titled “For-each”for (variable : expression) goes through an array, or a list string, once per element. The expression is worked out once, and the loop uses the length the array had at the start. Anything else runs zero times.
function onCreated() { for (temp.n : {1, 2, 3, 4, 5}) { if (temp.n == 3) { continue; } if (temp.n == 5) { break; } echo(temp.n); } // expect: 1 // expect: 2 // expect: 4}Run this example in the playground
switch
Section titled “switch”The value is worked out once. The cases are tried from the top with loose equality, so case "1": matches switch (1) and text cases ignore case. The first match starts running, and the code falls through to the next case until break. default may stand anywhere and runs when nothing matches. Case values do not have to be constants.
function onCreated() { switch ("B") { case "a": echo("first"); break; case "b": echo("second"); case "c": echo("falls through"); break; default: echo("none"); } // expect: second // expect: falls through}Run this example in the playground
enum and const
Section titled “enum and const”enum STATUS { WAITING, READY, STARTED } makes STATUS.WAITING equal to 0, STATUS.READY equal to 1, and so on. A value restarts the count: { RA, RB = 10, RC } makes RC equal to 11. An enum with no name, enum { A, B }, makes the bare names A and B.
const MAX_ITEMS = 7; makes a constant. At the top of a file it is visible in the whole file. Inside a function it is visible from its line to the end of the block. The value must be a constant expression: literals, other constants, arithmetic, and joining.
Assigning to either is a compile error (E-ASSIGN-CONST).
enum STATUS { WAITING, READY, STARTED }const MAX_ITEMS = 7;
function onCreated() { echo(STATUS.STARTED); // expect: 2 echo(MAX_ITEMS * 2); // expect: 14}Run this example in the playground
with (obj) statement runs the statement with this set to obj. When obj is empty or destroyed, the statement still runs, with this set to a new empty object, and nothing is reported (OQ-LANG-26).
try, catch, finally, throw (extension)
Section titled “try, catch, finally, throw (extension)”throw expression; raises an error whose message is the text of the expression and whose type is "script". Run-time errors that the engine raises inside a try can be caught too, with type "runtime".
catch (temp.err) receives an object with message, file, line, and type. finally always runs: after the block, after the catch, and when control leaves by return, break, continue, or an error nobody caught.
An error that leaves every try of the call is reported, ends the current function, and gives empty to the caller, which goes on.
function onCreated() { try { throw "boom"; } catch (temp.err) { echo("caught " @ temp.err.message); } finally { echo("done"); } // expect: caught boom // expect: done}Run this example in the playground
Creating objects and arrays
Section titled “Creating objects and arrays”new T(args) { init } makes an object of type T. Inside the block, this is the new object. The block needs no ; after it. new[n] and new[rows][columns] make arrays filled with empty values.
function onCreated() { temp.grid = new[2][3]; echo(temp.grid.size()); // expect: 2 echo(temp.grid[0].size()); // expect: 3}Run this example in the playground
Empty array literal
Section titled “Empty array literal”{} is allowed only as the whole right side of an assignment: temp.a = {};. It is a compile error anywhere else (E-EMPTY-ARRAY-POSITION), in return {}; or in a call. There are no object literals: {key: value} is E-OBJECT-LITERAL.
Forms accepted for legacy scripts
Section titled “Forms accepted for legacy scripts”Scripts written for the legacy server use a few forms that Bornescript accepts so they compile unchanged (specs language.md §3.10):
elseif (c) ...is the same aselse if (c) ....- Expressions joined by
,in a statement (a = 1, b = 2;) run one after the other, each like a statement of its own. - An
enumor a namedfunctionwritten inside a function body is a declaration of the whole script, as if it stood at the top level. - A stray
;before the)of aforheader is ignored. - A statement that starts with a name followed by a number or a text calls the function without parentheses:
sleep .5;,freezeplayer 3;. =<and=>are<=and>=.- A call without parentheses may also start with a bare name that ends the statement or is followed by a comma:
join gui_common;joins the class with that name andshowpoly index, {0, 0};passes the variableindex. - A top-level
constwritten after an unnamedenummay reuse the name of one of its members; theconstwins. returnright before}needs no;.- Statements before the first
caseof aswitchare accepted and never run.
Engine version 0.1.0. Built 2026-11-18.