but how to pass arbitrary chars to the config

This commit is contained in:
🪞👃🪞 2025-01-12 02:23:39 +01:00
parent f485a068a8
commit 19ed6a24b8
11 changed files with 627 additions and 644 deletions

View file

@ -9,8 +9,10 @@ pub enum Token<'a> {
Exp(&'a str, usize, usize, usize),
}
pub type ChompResult<'a> = Result<(&'a str, Token<'a>), ParseError>;
impl<'a> Token<'a> {
pub const fn chomp (source: &'a str) -> Result<(&'a str, Self), ParseError> {
pub const fn chomp (source: &'a str) -> ChompResult<'a> {
use Token::*;
use konst::string::{split_at, char_indices};
let mut state = Self::Nil;
@ -20,15 +22,17 @@ impl<'a> Token<'a> {
// must begin expression
Nil => match c {
' '|'\n'|'\r'|'\t' => Nil,
'(' => Exp(source, index, 1, 1),
':' => Sym(source, index, 1),
'(' => Exp(source, index, 1, 1),
':'|'@' => Sym(source, index, 1),
'0'..='9' => Num(source, index, 1),
'a'..='z' => Key(source, index, 1),
//'\'' => Chr(source, index, 1),
_ => return Err(ParseError::Unexpected(c))
},
Num(_, _, 0) => unreachable!(),
Sym(_, _, 0) => unreachable!(),
Key(_, _, 0) => unreachable!(),
//Chr(_, _, 0) => unreachable!(),
Num(source, index, length) => match c {
'0'..='9' => Num(source, index, length + 1),
' '|'\n'|'\r'|'\t' => return Ok((