A tiny, highly modular, embeddable, dynamically typed scripting language with a bytecode VM, intended for use in games.
[dependences]
raton = {
  version = "0",
  features = ["i32_type", "while_loop", "single_line_comment"],
  default-features = false
}// Add up all integers from 1 to n
fn sum_to_n(n) {
    let i = 0;
    let sum = 0;
    while (i < n) {
        i = i + 1;
        sum = sum + i;
    }
    return sum;
}- Parser
 - Bytecode generator
 - Bytecode VM
 - Optimizer
 - Debugger
 - Modular standard library
 
-  
null -  
bool(optionalbool_typefeature) -  
i32(optionali32_typefeature) -  
f32(optionalf32_typefeature) -  
string(optionalstring_typefeature) -  Host value (optional 
extern_valuefeature) - Host immutable/mutable reference
 
-  
if,else(optionalif_expressionfeature) -  
.method()(optionalmethod_call_expressionfeature) -  
while,break,continue(optionalwhile_loopfeature) -  
//comments (optionalsingle_line_commentfeature) -  
/* */comments (optionalmulti_line_commentfeature) 
-  
serde(ast and bytecode) -  
bitcode(bytecode only) 
- Portable to any platform, 32 bits or higher, supported by Rust
 - Parsing, code generation, and runtime have configurable limits
 - Error handling and reporting
 -  Optional error if an operation produces 
f32::NaN -  
no_std 
| Operation | Overhead | Heap allocations (amortized) | 
|---|---|---|
| Create VM (4 host fn's) | 150ns | 2 | 
| Host -> script fn call | 50ns | 0 | 
| Script -> host fn call | 20ns | 0 | 
Ratón takes ~0.4s on Fibonacci and ~0.05s on 1M Loop on an i7-7700k (see Rhai benchmarks).
Ratón is designed to handle untrusted or malicious source code, asts, or bytecode without panicking, exhausting memory, memory unsafety, exponential time complexity, or infinite loop. Unsafe code is forbidden, and each component has a fuzzer that tests it against arbitrary inputs.
TODO:
- Limit length of string values
 
You are responsible for using the limits, such as on instructions and call stack depth, that it provides.
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
 - MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
 
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.