Examples
The repository ships a set of runnable examples under examples/, one folder
per topic. Each is a complete .scr program you can run directly with the
interpreter:
./build/interpreter/scrii_repl examples/01_hello_world/hello.scr
Topic tour
Language fundamentals
| Folder | Topic | What it shows |
|---|---|---|
01_hello_world |
Hello world | Minimal program, print, basic script |
02_types |
Types | Every value type and literals |
03_control_flow |
Control flow | if/elif, while, for, foreach, switch |
04_functions |
Functions | Named/anonymous functions, arguments, returns |
05_arrays |
Arrays | Construction, indexing, nesting |
06_objects |
Objects | Key/value maps, nesting, access |
07_operators |
Operators | Arithmetic, comparison, logical, ternary, pipes |
08_strings |
Strings | Concatenation, methods, std.string |
Standard library
| Folder | Topic | What it shows |
|---|---|---|
09_math |
Math | std.math functions and constants |
10_file_io |
File I/O | std.file read/write basics |
11_json |
JSON | std.json parse/stringify |
12_sorting |
Sorting | std.sort algorithms |
15_time |
Time | std.time and timers |
16_hashing |
Hashing | std.hash md5/sha256/crc32 |
17_system |
System | std.system, std.env, process basics |
18_conversions |
Conversions | std.convert number/base/string conversion |
23_paths |
Paths | std.path resolution and decomposition |
27_compression |
Compression | std.compression zstd/lz4 |
28_images |
Images | std.image load/info/save with sample files |
Concurrency & networking
| Folder | Topic | What it shows |
|---|---|---|
14_async |
Concurrency | std.async spawn/await/defer |
24_sockets |
Sockets | std.net TCP/UDP |
25_http |
HTTP | std.net HTTP client/server |
26_crypto_files |
Crypto files | std.crypto encrypted file I/O |
Integration & advanced
| Folder | Topic | What it shows |
|---|---|---|
13_imports |
Imports | import() and multi-file projects (libs/) |
19_advanced_patterns |
Patterns | Idiomatic/advanced Scrii patterns |
20_text_adventure |
Game | A small text-adventure program |
21_plugins |
Plugins | load_plugin against a built shared library |
22_arg_parse |
CLI args | std.arg_parser + std.env.args() (run with args!) |
50_torture |
Stress | Aggressive use of the interpreter |
Some examples need build-time prerequisites to run fully:
21_pluginsrequires the plugin shared library built first (see
Native Plugins).26_crypto_files,25_http(TLS), and28_imagesneed the optional
OpenSSL / image backends to be present at build time, and
27_compressionneeds zstd/lz4 (see
Backends).
Suggested reading order
Start at 01_hello_world and work up roughly by folder number — the later
examples (14_async, 20_text_adventure, 24_sockets, 25_http) assume
the language and stdlib topics from the earlier ones.
Running the torture test
The 50_torture suite is a stress test more than a tutorial — run it after
installing a new build to shake out interpreter, concurrency, and stdlib
regressions before anything else. It hammers timers, defers, HTTP/TCP/UDP,
file/JSON/crypto/image churn concurrently for the whole run, prints progress
every ~5 s and a final SUMMARY, then cancels everything and exits 0 on a
clean run (any failure prints a STATUS: message line and exits nonzero):
./build/interpreter/scrii_repl examples/50_torture/main.scr 30
That runs for 30 seconds (default without the argument: 5 minutes).