Added support for emojis 😁

This commit is contained in:
elvis
2025-07-03 16:28:28 +02:00
parent e0a7c61baa
commit d419ebaafd
5 changed files with 20 additions and 8 deletions

View File

@ -11,7 +11,7 @@ fn main() -> std::io::Result<()> {
// std::thread::sleep(std::time::Duration::new(2, 0));
// println!("{}", now.elapsed().as_micros());
// examples::stats()?;
examples::stats()?;
// examples::freq()?;

View File

@ -17,13 +17,25 @@ grammar(translator: &mut Translator);
// Helpers
// -----------------------------------------------------------------------------
// order
match {
r"[0-9]+" => NUMBER
} else {
r"([[:alpha:]]|\p{Emoji})([[:word:]]|\p{Emoji})*" => WORD
} else {
_
}
// matches words (letter followed by numbers, letters or _)
Literal = { r"[[:alpha:]][[:word:]]*" };
Literal: String = {
WORD => <>.to_string()
};
// all numbers are i64
Num: i64 = {
r"[0-9]+" =>? i64::from_str(<>)
.map_err(|_| ParseError::User { error: "Number is too big" })
NUMBER =>? i64::from_str(<>)
.map_err(|_| ParseError::User { error: "Number is too big" })
};
// macro for matching sequence of patterns with C as separator