forked from AbleOS/ableos_userland
77 lines
1.1 KiB
Rust
77 lines
1.1 KiB
Rust
//! **note** the order of fields is the order of parsing.
|
|
|
|
/// An IDL module.
|
|
///
|
|
/// Parsing order:
|
|
/// - use declarations,
|
|
/// - items
|
|
#[derive(Debug)]
|
|
pub struct IDLModule {
|
|
// why: only allow use before other items
|
|
// parser will error if use is present in any other place
|
|
pub uses: Vec<UseDecl>,
|
|
pub items: Vec<Item>,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum Item {
|
|
Interface(ItemInterface),
|
|
Type(ItemAlias),
|
|
Constant(ItemConstant),
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct Function {
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ItemInterface {
|
|
pub name: String,
|
|
pub functions: Vec<Function>,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ItemAlias {
|
|
pub name: String,
|
|
pub referree: String,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct ItemConstant {
|
|
pub name: String,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub struct UseDecl {
|
|
pub module: String,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum Expr {
|
|
Literal(Literal),
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum Literal {
|
|
String(String),
|
|
Number(NumberLiteral),
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
pub enum NumberLiteral {
|
|
Ptr(usize),
|
|
|
|
U8(u8),
|
|
I8(i8),
|
|
|
|
U16(u16),
|
|
I16(i16),
|
|
|
|
U32(u32),
|
|
I32(i32),
|
|
|
|
U64(u64),
|
|
I64(i64),
|
|
}
|