Cylium Language Documentation
Language version: 0.1.1
Language Reference
Comments
Comments start with # and continue to the
end of the line.
# This is a comment
echo Hello World
Labels
Labels mark positions in code that can be jumped to using
goto.
start:
echo "Looping"
goto start
Variables and Constants
Declaration
Variables are declared with var, constants
with const.
var name = value
const PI = 3.14159
Types
Cylium has five built-in types:
- String - Text data (e.g.,
hello)
- Number - Integer values (e.g.,
42)
- Float - Floating-point values (e.g.,
3.14)
- Boolean - True/false values (e.g.,
true, false)
- Vector - Dynamic arrays
Type Conversion
Use the as operator to convert between
types:
var value = input
# Convert string to number
value as number
# Convert to floating point
value as float
# Convert to boolean
value as bool
# Convert string to vector of characters
value as vector
Vector Operations
Vectors can be created and manipulated:
# Empty vector
var vec = vector
# Vector with capacity
var vec = vector 10
# Vector with initial values
var vec = 1, 2, 3, 4, 5
# Add element
vec push 6
# Remove element by index
vec remove 2
# Access element
echo {vec[0]}
# Modify element
vec[0] = 10
vec[0] += 5
Built-in Constants
pi- Mathematical constant π
e- Euler’s number
sqrt_2- Square root of 2
tau- Mathematical constant τ (2π)
Memory Management
Use delete to free variable memory:
var temp = data
# Use temp...
delete temp
Operators
Arithmetic Operators
+- Addition or string concatenation
-- Subtraction
*- Multiplication or string repetition
/- Division
%- Modulo
Assignment Operators
=- Simple assignment
+=- Add and assign
-=- Subtract and assign
*=- Multiply and assign
/=- Divide and assign
%=- Modulo and assign
Comparison Operators
==- Equal to
!=- Not equal to
>- Greater than
<- Less than
>=- Greater than or equal to
<=- Less than or equal to
Logical Operators
and- Logical AND
or- Logical OR
not- Logical NOT
Control Flow
Conditional Statements
if condition then action
if condition then goto label
if condition then echo message
Else and Else If
if condition then action
else if condition then action
else action
Loops (via goto)
var i = 0
loop:
echo {i}
i += 1
if i < 10 then loop
Input/Output
Output with echo
echo Hello World
echo {variable}
echo Text with {variable} inside
Input
# Reads from standard input
var name = input
Exit Program
# Success
exit 0
# Error
exit 1
Special Vector Methods
Type Conversion for Vectors
Convert all elements in a vector:
# Convert all elements to numbers
vec as numbers
# Convert all elements to strings
vec as strings
# Convert all elements to floats
vec as floats
# Convert all elements to booleans
vec as bools
Vector Properties
# Get vector length
var length = vec[length]
# Get vector capacity
var capacity = vec[capacity]
# Remove duplicates
vec unique
String Interpolation
Use {} to embed expressions within
strings:
var name = World
# Output: Hello World!
echo Hello {name}!
# Output: Result: 11
echo Result: {5 + 3 * 2}
Best Practices
- Use labels for readability - Instead of
line numbers in goto statements
- Manage memory explicitly - Delete
variables when no longer needed
- Comment complex logic - Use comments
for non-obvious control flow
- Validate input - Convert and check user input early