2024-02-21 16:04:18 +00:00
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
#[allow(clippy::extra_unused_lifetimes)]
|
|
|
|
#[allow(clippy::needless_lifetimes)]
|
|
|
|
#[allow(clippy::let_unit_value)]
|
|
|
|
#[allow(clippy::just_underscores_and_digits)]
|
|
|
|
#[allow(clippy::pedantic)]
|
|
|
|
mod parser {
|
2024-02-22 19:27:35 +00:00
|
|
|
pub use __intern_token::new_builder as new_builder;
|
2024-02-21 16:04:18 +00:00
|
|
|
include!(concat!(env!("OUT_DIR"),"/parser.rs"));
|
|
|
|
}
|
|
|
|
mod parser_util;
|
|
|
|
mod vm;
|
|
|
|
mod symbol;
|
|
|
|
|
|
|
|
pub mod ast;
|
|
|
|
pub mod value;
|
|
|
|
pub mod gc;
|
|
|
|
pub mod chunk;
|
|
|
|
pub mod compiler;
|
|
|
|
|
|
|
|
pub use parser::BlockParser as Parser;
|
|
|
|
pub use vm::Vm;
|
|
|
|
pub use symbol::Symbol;
|
2024-02-22 19:27:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
type LexResult<'input> = Result<
|
|
|
|
(usize, Token<'input>, usize),
|
|
|
|
ParseError<usize, Token<'input>, parser_util::ParseError>
|
|
|
|
>;
|
|
|
|
|
|
|
|
use lalrpop_util::{ParseError, lexer::{Token, MatcherBuilder}};
|
|
|
|
|
|
|
|
pub struct Lexer {
|
|
|
|
builder: MatcherBuilder,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Lexer {
|
|
|
|
fn default() -> Self { Self::new() }
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Lexer {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self { builder: crate::parser::new_builder() }
|
|
|
|
}
|
|
|
|
pub fn lex<'s>(&'s self, input: &'s str) -> impl Iterator<Item=LexResult<'s>> {
|
|
|
|
self.builder.matcher::<parser_util::ParseError>(input)
|
|
|
|
}
|
|
|
|
}
|