A minimalist interpreter for the bloa scripting language.
- Variables and expressions (arithmetic, logic, comparison)
- Control flow: if/else, while, for-in, repeat
- Functions with parameters
- Classes with methods and inheritance (
extends) - Modules:
usefor importing,requirefor including files - Built-in functions: print, range, len, str, int, float, append
- Lists, strings, numbers, booleans
- I/O: say (print), ask (input)
- Exception handling: try/except
- Standard library in
stdlib/(math, io, string)
x = 42
y = x + 10
say "Result: " + str(y)
function greet(name) {
say "Hello, " + name
}
greet("World")
class Animal {
function speak(self) {
say "Animal sound"
}
}
class Dog extends Animal {
function speak(self) {
say "Woof!"
}
}
d = Dog()
d.speak()
use math;
say "Square root of 4: " + str(sqrt(4))
The standard library is built-in and automatically available, providing functions without requiring external files:
sqrt(x): Square rootpow(base, exp): Powersin(x),cos(x),tan(x): Trigonometric functionslog(x),exp(x): Logarithm and exponentialabs(x): Absolute valuefloor(x),ceil(x),round(x): Rounding functionspi(),e(): Mathematical constants
read_file(path): Read file content as stringwrite_file(path, content): Write string to fileexists(path): Check if file/directory existslist_dir(path): List directory contents as list of stringsmkdir(path): Create directoryrmdir(path): Remove directoryremove(path): Remove filecopy_file(from, to): Copy filemove(from, to): Move/rename filefile_size(path): Get file size in bytesis_dir(path): Check if path is a directory
len(s): String length (built-in)split(s, delim): Split string by delimiterjoin(list, sep): Join list of strings with separatorsubstr(s, start, len?): Substringfind(s, sub): Find substring positionreplace(s, old, new): Replace all occurrencesto_upper(s),to_lower(s): Case conversiontrim(s): Remove leading/trailing whitespacestarts_with(s, prefix): Check if string starts with prefixends_with(s, suffix): Check if string ends with suffixcontains(s, sub): Check if string contains substringreverse(s): Reverse stringrepeat(s, n): Repeat string n times
random_int(max)orrandom_int(min, max): Random integerrandom_float(max)orrandom_float(min, max): Random floatnow(): Current timestamp in milliseconds
All functions are available globally.
say "Square root of 16: " + str(sqrt(16))
say "Pi value: " + str(pi())
say "Uppercase: " + to_upper("hello")
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .To create Debian packages for amd64 and i386 (requires multilib tools):
# amd64
mkdir -p package_amd64/DEBIAN package_amd64/usr/local/bin
cp build/bloa package_amd64/usr/local/bin/
# edit control fields then
chmod 0755 package_amd64/DEBIAN
sudo dpkg-deb --build package_amd64 bloa_0.2.0-alpha_amd64.deb
# i386 (after installing g++-multilib libc6-dev-i386)
rm -rf build32 && mkdir build32 && cd build32
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 ..
cmake --build .
mkdir -p package_i386/DEBIAN package_i386/usr/local/bin
cp bloa ../package_i386/usr/local/bin/
# edit control & build
chmod 0755 package_i386/DEBIAN
sudo dpkg-deb --build package_i386 bloa_0.2.0-alpha_i386.deb
# all architecture (use when you just want a generic package, e.g. containing
# scripts or the prebuilt binary for the current host; the package is marked
# "Architecture: all" so dpkg will install it regardless of machine type)
mkdir -p package_all/DEBIAN package_all/usr/local/bin
# copy whatever payload makes sense; we'll just include amd64 binary here as an
# example, but you can replace it with a shell wrapper or source archive
cp build/bloa package_all/usr/local/bin/
cat > package_all/DEBIAN/control <<'EOF'
Package: bloa
Version: 0.2.0-alpha
Section: utils
Priority: optional
Architecture: all
Maintainer: bloa <noreply@local>
Description: bloa language runtime (architecture independent "all" package)
EOF
chmod 0755 package_all/DEBIAN
sudo dpkg-deb --build package_all bloa_0.2.0-alpha_all.deb```
## Releases
A GitHub Actions workflow (`.github/workflows/release.yml`) builds both architectures and packages `.deb` files when a tag is pushed.