| Crates.io | ovsm |
| lib.rs | ovsm |
| version | 1.0.0 |
| created_at | 2025-10-13 10:51:29.118765+00 |
| updated_at | 2025-10-13 10:51:29.118765+00 |
| description | OVSM (Open Versatile Seeker Mind) language interpreter for blockchain automation and scripting |
| homepage | https://github.com/opensvm/osvm-cli |
| repository | https://github.com/opensvm/osvm-cli |
| max_upload_size | |
| id | 1880370 |
| size | 446,598 |
A production-ready interpreter for the OVSM scripting language, designed for blockchain automation, data processing, and general-purpose scripting.
✨ Complete Language Implementation
🚀 Production Ready
📚 Well Documented
Add to your Cargo.toml:
[dependencies]
ovsm = "1.0.0"
use ovsm::{Evaluator, Parser, Scanner, Value};
fn execute_ovsm(code: &str) -> Result<Value, Box<dyn std::error::Error>> {
let mut scanner = Scanner::new(code);
let tokens = scanner.scan_tokens()?;
let mut parser = Parser::new(tokens);
let program = parser.parse()?;
let mut evaluator = Evaluator::new();
Ok(evaluator.execute(&program)?)
}
fn main() {
let code = r#"
$sum = 0
FOR $i IN [1..11]:
$sum = $sum + $i
RETURN $sum
"#;
match execute_ovsm(code) {
Ok(result) => println!("Result: {:?}", result), // Int(55)
Err(err) => eprintln!("Error: {}", err),
}
}
$x = 10
$y = 20
RETURN $x + $y // 30
$score = 85
IF $score >= 90 THEN
RETURN "A"
ELSE
IF $score >= 80 THEN
RETURN "B"
ELSE
RETURN "C"
$sum = 0
FOR $i IN [1..20]:
IF $i % 2 == 0 THEN
CONTINUE
IF $i > 15 THEN
BREAK
$sum = $sum + $i
RETURN $sum // Sum of odd numbers 1-15
$numbers = [1, 2, 3, 4, 5]
$sum = 0
FOR $num IN $numbers:
$sum = $sum + $num
RETURN $sum / 5 // Average
The crate includes an example runner for executing .ovsm script files:
cargo run --example run_file script.ovsm
Example scripts are provided in the examples/ directory.
Launch an interactive Read-Eval-Print Loop:
cargo run --example simple_repl
IF/THEN/ELSE - Conditional executionFOR ... IN - Iterate over arrays, ranges, stringsWHILE - Loop while condition is trueBREAK / BREAK IF - Exit loops earlyCONTINUE / CONTINUE IF - Skip iterationsRETURN - Return values[1, 2, 3], Objects {name: "Alice"}[1..10] (exclusive end)+, -, *, /, %, ** (power)<, >, <=, >=, ==, !=AND, OR, NOTcondition ? then : elseIN (check if item in collection)$variable = valueCONST NAME = valueAll public APIs are thoroughly documented with:
Error messages include:
TRY/CATCH error handling is experimentalContributions are welcome! Please see our Contributing Guide.
Licensed under the MIT License.
Check out the examples directory for more:
hello_world.ovsm - Basic greetingfactorial.ovsm - Calculate factorialsfibonacci.ovsm - Generate Fibonacci numbersarray_operations.ovsm - Array manipulationconditional_logic.ovsm - Complex conditionalsloop_control.ovsm - Advanced loop controlMade with ❤️ by the OpenSVM team