Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for classes containing numbers in their names #336

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions maud_macros/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
Expand Down