evalit 0.1.0

a toy interpreter
Documentation
evalit
======

A toy interpreter.

# example

```rust
use evalit::{Interpreter, Evaluator};

fn main() {
    let mut env = Environment::new();

    let script = r#"
    fn fib(n) {
        if n <= 0 {
            return 0;
        }
        if n <= 2 {
            return 1;
        }

        return fib(n-1) + fib(n-2);
    }

    let sum = 0;
    for i in 0..=10 {
        sum += fib(i);
    }

    return sum;
    "#;

    let retval = Interpreter::eval_script(script, env).unwrap();

    println!("ret: {:?}", ret); 
    // should output: 
    // ret: Some(143)
}


```

# syntax

## primitive type

### null

### boolean

`true`, `false`

### integer

$-2^{63}$ ~ $2^{63}$

### float

float number, f64.

### string

string quote by `"`

## control flow

### loop

`loop` to repeat.

```rust
loop {}
```

### while

`while` to repeat.

```rust
while condition {}
```

### for

`for` to iterate.

```rust
for i in 0..=10 {}
```

### if 

`if` to choose branch.

```rust
if condition {} else {}
```

### break

`break` to exist loop.

### continue

`continue` to finish one iterate.

### return

`return` to return value.

## fn 

### user defined function

```rust
fn fib(n) {
    if n <= 0 {
        return 0;
    }
    if n <= 2 {
        return 1;
    }

    return fib(n-1) + fib(n-2);
}
```