#[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 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 terms: Vec<Term>,
pub name: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Term {
Symbol(String),
Optional(String),
ZeroOrMore(String),
OneOrMore(String),
SeparatedBy { symbol: String, sep: String },
Empty,
}