BraneScript Reference
BraneScript Reference
Section titled “BraneScript Reference”BraneScript is a workflow language for orchestrating distributed computations. This page is a concise reference for the language syntax and features.
Statements
Section titled “Statements”All statements end with a semicolon:
let x := 42;println(x);Variables
Section titled “Variables”let name := "value"; // Stringlet count := 42; // Integerlet ratio := 3.14; // Reallet flag := true; // Booleanlet items := [1, 2, 3]; // ArrayReassignment:
let x := 1;x := 2;Operators
Section titled “Operators”Arithmetic
Section titled “Arithmetic”| Operator | Description |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo |
Comparison
Section titled “Comparison”| Operator | Description |
|---|---|
== | Equal |
!= | Not equal |
< | Less than |
> | Greater than |
<= | Less than or equal |
>= | Greater than or equal |
Logical
Section titled “Logical”| Operator | Description |
|---|---|
&& | And |
| ` | |
! | Not |
Control Flow
Section titled “Control Flow”If/Else
Section titled “If/Else”if condition { // ...} else if other_condition { // ...} else { // ...}while condition { // ...}for item in collection { // ...}Functions
Section titled “Functions”Importing Packages
Section titled “Importing Packages”import package_name;Calling Functions
Section titled “Calling Functions”let result := function_name(arg1, arg2);Defining Functions
Section titled “Defining Functions”func add(a, b) { return a + b;}Creating a Data Reference
Section titled “Creating a Data Reference”let data := new Data { name := "dataset_name" };Passing Data to Functions
Section titled “Passing Data to Functions”let result := process(data);Classes
Section titled “Classes”Defining a Class
Section titled “Defining a Class”class Point { x: Integer; y: Integer;}Creating Instances
Section titled “Creating Instances”let p := new Point { x := 10, y := 20 };Accessing Fields
Section titled “Accessing Fields”println(p.x);Arrays
Section titled “Arrays”let numbers := [1, 2, 3, 4, 5];let first := numbers[0];let length := len(numbers);Built-in Functions
Section titled “Built-in Functions”| Function | Description |
|---|---|
println(value) | Print a value to output |
len(array) | Get array length |
commit_result(name, value) | Store a named result |
Comments
Section titled “Comments”// Single-line comment
/* Multi-line comment */String Operations
Section titled “String Operations”let greeting := "Hello, " + "world!";let length := len(greeting);Type Casting
Section titled “Type Casting”let s := to_string(42);let n := to_int("42");let f := to_real("3.14");