mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-26 03:33:44 +03:00
fix package names
This commit is contained in:
parent
ed41a55c47
commit
e492950106
@ -162,18 +162,35 @@ impl ParserContext {
|
||||
|
||||
pub fn parse_package_name(&mut self) -> SyntaxResult<Identifier> {
|
||||
// Build the package name, starting with valid characters up to a dash `-` (Token::Minus).
|
||||
let mut base = self.expect_loose_identifier()?;
|
||||
let mut base = self.expect_loose_ident()?;
|
||||
|
||||
// Build the rest of the package name including dashes.
|
||||
while let Some(token) = self.eat(Token::Minus) {
|
||||
if token.span.line_start == base.span.line_stop && token.span.col_start == base.span.col_stop {
|
||||
base.name += "-";
|
||||
base.span = base.span + token.span;
|
||||
let next = self.expect_loose_identifier()?;
|
||||
base.name += &next.name;
|
||||
base.span = base.span + next.span;
|
||||
} else {
|
||||
break;
|
||||
loop {
|
||||
match &self.peek()?.token {
|
||||
Token::Minus => {
|
||||
let span = self.expect(Token::Minus)?;
|
||||
base.name += "-";
|
||||
base.span = base.span + span;
|
||||
let next = self.expect_loose_ident()?;
|
||||
base.name += &next.name;
|
||||
base.span = base.span + next.span;
|
||||
},
|
||||
Token::Int(_) => {
|
||||
let (num, span) = self.eat_int().unwrap();
|
||||
base.name += &num.value;
|
||||
base.span = base.span + span;
|
||||
},
|
||||
Token::Ident(_) => {
|
||||
let next = self.expect_ident()?;
|
||||
base.name += &next.name;
|
||||
base.span = base.span + next.span;
|
||||
},
|
||||
x if KEYWORD_TOKENS.contains(&x) => {
|
||||
let next = self.expect_loose_ident()?;
|
||||
base.name += &next.name;
|
||||
base.span = base.span + next.span;
|
||||
},
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user