token.rs: Allow one-character identifiers

This commit is contained in:
John 2023-08-19 23:56:26 -05:00
parent f89d2ddfdd
commit 8947521181

View File

@ -50,7 +50,7 @@ impl<$t> From<&$t str> for $type {
token token
} else } else
)* )*
{todo!("Unexpected input: {value:#?}")} {todo!("Unexpected input: {value:#?} (Tokenization failure)")}
} }
} }
}; };
@ -221,7 +221,7 @@ regex_impl! {<'text> Token<'text> {
regex!(Type::Directive = r"^\.\w+( .*)?") regex!(Type::Directive = r"^\.\w+( .*)?")
} }
pub fn expect_identifier(text: &str) -> Option<Self> { pub fn expect_identifier(text: &str) -> Option<Self> {
regex!(Type::Identifier = r"^[A-Za-z_]\w+") regex!(Type::Identifier = r"^[A-Za-z_]\w*")
} }
pub fn expect_separator(text: &str) -> Option<Self> { pub fn expect_separator(text: &str) -> Option<Self> {
regex!(Type::Separator = r"^,") regex!(Type::Separator = r"^,")