Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

Documentation

Kick de Gans edited this page May 18, 2024 · 25 revisions

Documentation for Beryllium

1: Basics
2: If statements
3: Loops

1: Basics:

Using the interpreter:

Checking if the runtime is properly installed:

Opening and running a file:

beryllium file.ber

IO:

Printing text:

puts("Hello world!"); /* Print without newline */

User input:

input("Enter your name:"); /* Returns the value the user inputted */

Reading and writing to files:

var file = open("file", options); /* Open file */
// options: R for reading basic text. RB for reading bytes. W for writing text. WB for writing bytes
file.read(); /* Read file */
file.write("content"); /* Write to file/stream */

Variables:

Declaring variables:

var foo = value; /* Any type */

Declaring constant variables (Readonly):

val foo = value; /* Any type */

Declaring public variables (Global):

global var foo = value; /* Any type */

You can also use global val to make a constant public variable

Functions:

Declaring functions:

fun foo() { /* No arguments*/
    ...
}
fun foo(bar) { /* Arguments */
    ...
}

2: If statements:

if (condition) { /* If statement */
    ...
}
else if (condition) {
    ...
}
else {
    ...
}

3: Loops:

Normal loops:

while (condition) {
    ...
}

For loop:

for (var i = 0; i < 5; i = i + 1) {
    ...
}

Foreach loop:

foreach (x in source) {
    ...
}