ffi-gen 0.1.13

Call rust from any language.
Documentation
ident = @{ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")* }

primitive = {
    "u8" | "u16" | "u32" | "u64" | "usize" |
    "i8" | "i16" | "i32" | "i64" | "isize" |
    "bool" | "f32" | "f64" | "string"
}
tuple = { "(" ~ (type_ ~ ("," ~ type_)*)? ~ ","? ~ ")" }
ref_ = { "&" ~ type_ }
slice = { "[" ~ type_ ~ "]" }
vec = { "Vec" ~ "<" ~ type_ ~ ">" }
opt = { "Option" ~ "<" ~ type_ ~ ">" }
res = { "Result" ~ "<" ~ type_ ~ ">" }
iter = { "Iterator" ~ "<" ~ type_ ~ ">" }
fut = { "Future" ~ "<" ~ type_ ~ ">" }
stream = { "Stream" ~ "<" ~ type_ ~ ">" }
type_ = { primitive | tuple | ref_ | slice | vec | opt | res | iter | fut | stream | ident }

doc = @{ (!"\n" ~ ANY)* ~ "\n" }
module_docs = @{ "//!" ~ doc }
item_docs = @{ "///" ~ doc }
static_ = { "static" }
arg = { ident ~ ":" ~ type_ }
args = { (arg ~ ("," ~ arg)*)? }
function = { item_docs* ~ static_? ~ "fn" ~ ident ~ "(" ~ args ~ ")" ~ ("->" ~ type_)?  ~ ";" }
object = { item_docs* ~ "object" ~ ident ~ "{" ~ function* ~ "}" }

root = { SOI ~ module_docs* ~ (object | function)* ~ EOI }

WHITESPACE = _{ " " | "\t" | "\n" | "\r" }
COMMENT = _{ ("/*" ~ (!"*/" ~ ANY)* ~ "*/") | ("//" ~ !("/" | "!" | "\n") ~ (!"\n" ~ ANY)* ~ "\n") }