fix single-char variable names

This commit is contained in:
Pascal Kuthe 2023-03-19 20:40:33 +01:00 committed by Blaž Hrastnik
parent cabb746b7d
commit 617f09adc4

View File

@ -196,7 +196,8 @@ mod parser {
fn var<'a>() -> impl Parser<'a, Output = &'a str> { fn var<'a>() -> impl Parser<'a, Output = &'a str> {
// var = [_a-zA-Z][_a-zA-Z0-9]* // var = [_a-zA-Z][_a-zA-Z0-9]*
move |input: &'a str| match input move |input: &'a str| {
input
.char_indices() .char_indices()
.take_while(|(p, c)| { .take_while(|(p, c)| {
*c == '_' *c == '_'
@ -207,12 +208,11 @@ mod parser {
} }
}) })
.last() .last()
{ .map(|(index, c)| {
Some((index, c)) if index >= 1 => {
let index = index + c.len_utf8(); let index = index + c.len_utf8();
Ok((&input[index..], &input[0..index])) (&input[index..], &input[0..index])
} })
_ => Err(input), .ok_or(input)
} }
} }