slipknot 0.1.0

Parsing ANTLR v4 grammar using Rust's nom library.
Documentation
mod parser;

pub use parser::parse_grammar;

#[derive(Debug)]
pub struct Grammar {
    pub rules: Vec<Rule>,
}

#[derive(Debug)]
pub enum Rule {
    LexerRule(LexerRule),
    ParserRule(ParserRule),
}

#[derive(Debug)]
pub struct LexerRule {
    pub token_ref: String,
    pub lexer_alt_list: Vec<LexerAlt>,
}

#[derive(Debug)]
pub struct LexerAlt {
    pub lexer_elements: Vec<LexerElement>,
}

#[derive(Debug)]
pub struct LexerElement {
    pub lexer_atom: LexerAtom,
    pub ebnf_suffix: Option<EbnfSuffix>,
}

#[derive(Debug)]
pub enum LexerAtom {
    Terminal(Terminal),
    CharacterRange(CharacterRange),
    LexerCharSet(LexerCharSet),
}

#[derive(Debug)]
pub enum Terminal {
    TokenRef(String),
    Literal(String),
}

#[derive(Debug)]
pub struct CharacterRange {
    pub start: char,
    pub end: char,
}

#[derive(Debug)]
pub struct LexerCharSet {
    pub chars: Vec<LexerChar>,
}

#[derive(Debug)]
pub enum LexerChar {
    SingleCharacter(char),
    CharacterRange(CharacterRange),
}

#[derive(Debug)]
pub enum EbnfSuffix {
    Question,
    Star,
    Plus,
}

#[derive(Debug)]
pub struct ParserRule {
    pub rule_ref: String,
    pub alt_list: Vec<Alternative>,
}

#[derive(Debug)]
pub struct Alternative {
    pub elements: Vec<Element>,
}

#[derive(Debug)]
pub enum Element {
    AtomElement(AtomElement),
    EbnfElement(EbnfElement),
}

#[derive(Debug)]
pub struct AtomElement {
    pub atom: Atom,
    pub ebnf_suffix: Option<EbnfSuffix>,
}

#[derive(Debug)]
pub enum Atom {
    Terminal(Terminal),
    RuleRef(String),
}

#[derive(Debug)]
pub struct EbnfElement {
    pub block: Vec<Alternative>,
    pub ebnf_suffix: Option<EbnfSuffix>,
}