mirror of
https://github.com/AleoHQ/leo.git
synced 2024-11-28 19:23:24 +03:00
cleaner way to remove _ from beginning of idents
This commit is contained in:
parent
62e68f42da
commit
026816f085
@ -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!(
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user