From 1a1487b7f73f424add11276de6592812dedb9e9e Mon Sep 17 00:00:00 2001 From: Ivan Chinenov Date: Tue, 29 Mar 2022 12:18:53 +0300 Subject: [PATCH] Support for classes containing numbers in their names --- maud_macros/src/parse.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/maud_macros/src/parse.rs b/maud_macros/src/parse.rs index dee037e4..8c29e356 100644 --- a/maud_macros/src/parse.rs +++ b/maud_macros/src/parse.rs @@ -708,19 +708,28 @@ impl Parser { } else { return None; } - let mut expect_ident = false; + let mut expect_ident_or_number = false; loop { - expect_ident = match self.peek() { + expect_ident_or_number = match self.peek() { Some(TokenTree::Punct(ref punct)) if punct.as_char() == '-' => { self.advance(); result.push(TokenTree::Punct(punct.clone())); true } - Some(TokenTree::Ident(ref ident)) if expect_ident => { + Some(TokenTree::Ident(ref ident)) if expect_ident_or_number => { self.advance(); result.push(TokenTree::Ident(ident.clone())); false } + Some(TokenTree::Literal(ref lit)) + if expect_ident_or_number + // wtf why isn't there a way to get literal type from Literal + && lit.to_string().chars().all(|c| c.is_numeric()) => + { + self.advance(); + result.push(TokenTree::Literal(lit.clone())); + false + } _ => break, }; }