weezy20/loxz
Lox programming language bytecode VM implementation in Zig.
refs
Interpret a lox file. A lox file must have .lox
extension.
Some sample programs are provided in the programs
folder.
loxz <OPTIONS> <file.lox>
Run in REPL mode
loxz <OPTIONS>
Flags:
Flag | Description |
---|---|
-h , --help |
Show help message |
-t , --stack-tracing |
Enable VM stack tracing |
-d , --debug |
Enable debug output, set debug level |
OP_CONSTANT_LONG
. This instruction is emitted only after 8-bit space for constants have been exhausted.
pool have been exhausted.%
modulo operation.switch/case
. Check out switch-case.lox example. Supports upto 64 nested switch blocks. No break
keyword required, only one switch case executes.The interpreter includes several built-in native functions with runtime error reporting:
clock()
- Returns the current timestamp in seconds since epochsqrt(number)
- Returns the square root of a number (requires non-negative input)abs(number)
- Returns the absolute value of a numberpow(base, exponent)
- Returns base raised to the power of exponentAll native functions perform argument validation and provide descriptive error messages for invalid inputs. See test_native.lox for usage examples.