utterance 0.2.0

A parser library for creating readable, natural-language-inspired domain-specific languages.
Documentation
use crate::lexer::{Number, Symbol, Word};
use crate::syntax::HighlightKind;

pub enum Statement<'word> {
    Noop,
    Word(Word<'word>),
    Symbol(Symbol),
    DoubleSymbol(Symbol),
    NewLineOrEnd,
    Number(Number),
    Comment,
}

impl<'a> Statement<'a> {
    pub(crate) fn highlight_kind(&self) -> HighlightKind {
        match self {
            Statement::Word(w) => w.highligh_kind(),
            Statement::Symbol(_) => HighlightKind::Keyword,
            Statement::Number(_) => HighlightKind::Number,
            Statement::Comment => HighlightKind::Comment,
            Statement::Noop | Statement::DoubleSymbol(_) | Statement::NewLineOrEnd => {
                HighlightKind::None
            }
        }
    }
}