summaryrefslogtreecommitdiff
path: root/matrix-lang/src/lib.rs
blob: 1452a0978d0f47576b3225f006bed050fcde4ca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
mod compiler;
mod value;
mod lex;
mod vm;
mod parse;
mod chunk;
mod ast;
mod binary;

pub mod prelude;

#[macro_export]
macro_rules! iter {
    ($fn:expr) => {
        $crate::prelude::Value::Iter(
            ::std::rc::Rc::new(
                $crate::prelude::Function {
                    name: ::std::rc::Rc::from("<iterator>"),
                    arity: 0,
                    variadic: false,
                    fun: $crate::prelude::InnerFunction::Native(
                        ::std::rc::Rc::new($fn
        ))}))
    };
}

#[macro_export]
macro_rules! native {
    ($name:expr, $arity:expr, $varadic:expr, $fn:expr) => {
        $crate::prelude::Value::Function(
            ::std::rc::Rc::new( $crate::prelude::Function {
                name: std::rc::Rc::from($name),
                arity: $arity,
                variadic: $varadic,
                fun: $crate::prelude::InnerFunction::Native(
                    ::std::rc::Rc::new($fn)
                )
            })
        )
    }
}