cleaner way to remove _ from beginning of idents

This commit is contained in:
gluax 2021-03-23 16:45:43 -04:00
parent 62e68f42da
commit 026816f085
3 changed files with 4 additions and 8 deletions

View File

@ -72,10 +72,6 @@ impl SyntaxError {
)
}
pub fn invalid_ident_name(got: &str, expected: &str, span: &Span) -> Self {
Self::new_from_span(format!("expected identifier {} -- got '{}'", expected, got), span)
}
pub fn unexpected_ident(got: &str, expected: &[&str], span: &Span) -> Self {
Self::new_from_span(
format!(

View File

@ -302,9 +302,9 @@ impl ParserContext {
span,
} = token
{
if name.starts_with('_') {
return Err(SyntaxError::invalid_ident_name(&name, &name[1..name.len()], &span));
}
// if name.starts_with('_') {
// return Err(SyntaxError::invalid_ident_name(&name, &name[1..name.len()], &span));
// }
Ok(Identifier { name, span })
} else {

View File

@ -43,7 +43,7 @@ fn eat_identifier(input: &[u8]) -> Option<(&[u8], &[u8])> {
if input.is_empty() {
return None;
}
if !input[0].is_ascii_alphabetic() && input[0] != b'_' {
if !input[0].is_ascii_alphabetic() {
return None;
}
let mut i = 1usize;