protospec-build 0.3.0

One binary format language to rule them all, One binary format language to find them, One binary format language to bring them all and in the darkness bind them.
Documentation
use super::*;

pub fn parse_ffi_declaration(t: &mut TokenIter) -> ParseResult<FfiDeclaration> {
    let start = t.expect(Token::ImportFfi)?;
    let name = t.expect_ident()?;
    t.expect(Token::As)?;
    let typ = t.expect_oneof(&[Token::Transform, Token::Type, Token::Function])?;

    Ok(FfiDeclaration {
        span: start + typ.span,
        name,
        ffi_type: match typ.token {
            Token::Transform => FfiType::Transform,
            Token::Type => FfiType::Type,
            Token::Function => FfiType::Function,
            _ => unimplemented!(),
        },
    })
}