#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SymbolId(pub u32);
impl SymbolId {
pub const EOF: SymbolId = SymbolId(0);
}
#[derive(Debug, Clone)]
pub struct Grammar {
pub name: String,
pub start: String,
pub mode: String,
pub expect_rr: usize,
pub expect_sr: usize,
pub terminals: Vec<TerminalDef>,
pub rules: Vec<Rule>,
}
#[derive(Debug, Clone)]
pub struct ExpectDecl {
pub count: usize,
pub kind: String,
}
#[derive(Debug, Clone)]
pub struct TerminalDef {
pub name: String,
pub type_name: Option<String>,
pub is_prec: bool,
}
#[derive(Debug, Clone)]
pub struct Rule {
pub name: String,
pub result_type: Option<String>,
pub alts: Vec<Alt>,
}
#[derive(Debug, Clone)]
pub struct Alt {
pub symbols: Vec<SymbolRef>,
pub name: Option<String>,
}
#[derive(Debug, Clone)]
pub struct SymbolRef {
pub name: String,
pub modifier: SymbolModifier,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum SymbolModifier {
None,
Optional,
ZeroOrMore,
OneOrMore,
SeparatedBy(String),
Empty,
}