pub use keywords::ValkyrieKeywords;
pub use token_type::ValkyrieTokenType;
use crate::ValkyrieLanguage;
use oak_core::{
Lexer, LexerState, TextEdit,
lexer::{LexOutput, LexerCache},
source::Source,
};
pub(crate) type State<'a, S> = LexerState<'a, S, ValkyrieLanguage>;
#[derive(Clone)]
pub struct ValkyrieLexer<'config> {
pub(crate) config: &'config ValkyrieLanguage,
}
impl<'config> Lexer<ValkyrieLanguage> for ValkyrieLexer<'config> {
fn lex<'a, S: Source + ?Sized>(&self, source: &'a S, _edits: &[TextEdit], cache: &'a mut impl LexerCache<ValkyrieLanguage>) -> LexOutput<ValkyrieLanguage> {
let mut state = State::new(source);
let result = self.run(&mut state);
if result.is_ok() {
state.add_eof();
}
state.finish_with_cache(result, cache)
}
}
impl<'config> ValkyrieLexer<'config> {
pub fn new(config: &'config ValkyrieLanguage) -> Self {
Self { config }
}
}
pub mod token_type;
pub mod keywords;
mod lex;