talc/talc-lang/src/lib.rs

51 lines
1.1 KiB
Rust
Raw Normal View History

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;
2024-02-23 19:54:34 +00:00
pub mod symbol;
2024-02-21 16:04:18 +00:00
pub mod ast;
pub mod value;
2024-02-28 15:46:42 +00:00
pub mod exception;
2024-02-21 16:04:18 +00:00
pub mod chunk;
pub mod compiler;
2024-03-30 16:21:09 +00:00
pub mod lstring;
2024-02-21 16:04:18 +00:00
pub use parser::BlockParser as Parser;
pub use vm::Vm;
2024-02-22 19:27:35 +00:00
2024-02-27 05:18:43 +00:00
pub use parser_util::{parse_int, parse_float, parse_str_escapes};
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)
}
}