Deduplicate recipe parsing (#923)
This commit is contained in:
parent
ce0376cfdf
commit
9ee1a63e99
@ -322,35 +322,21 @@ impl<'tokens, 'src> Parser<'tokens, 'src> {
|
||||
break;
|
||||
} else if self.next_is(Identifier) {
|
||||
match Keyword::from_lexeme(next.lexeme()) {
|
||||
Some(Keyword::Alias) =>
|
||||
if self.next_are(&[Identifier, Identifier, Equals]) {
|
||||
return Err(self.get(2)?.error(CompileErrorKind::DeprecatedEquals));
|
||||
} else if self.next_are(&[Identifier, Identifier, ColonEquals]) {
|
||||
items.push(Item::Alias(self.parse_alias()?));
|
||||
} else {
|
||||
let doc = pop_doc_comment(&mut items, eol_since_last_comment);
|
||||
items.push(Item::Recipe(self.parse_recipe(doc, false)?));
|
||||
},
|
||||
Some(Keyword::Export) =>
|
||||
if self.next_are(&[Identifier, Identifier, Equals]) {
|
||||
return Err(self.get(2)?.error(CompileErrorKind::DeprecatedEquals));
|
||||
} else if self.next_are(&[Identifier, Identifier, ColonEquals]) {
|
||||
self.presume_keyword(Keyword::Export)?;
|
||||
items.push(Item::Assignment(self.parse_assignment(true)?));
|
||||
} else {
|
||||
let doc = pop_doc_comment(&mut items, eol_since_last_comment);
|
||||
items.push(Item::Recipe(self.parse_recipe(doc, false)?));
|
||||
},
|
||||
Some(Keyword::Set) =>
|
||||
Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, Equals]) =>
|
||||
return Err(self.get(2)?.error(CompileErrorKind::DeprecatedEquals)),
|
||||
Some(Keyword::Alias) if self.next_are(&[Identifier, Identifier, ColonEquals]) =>
|
||||
items.push(Item::Alias(self.parse_alias()?)),
|
||||
Some(Keyword::Export) if self.next_are(&[Identifier, Identifier, Equals]) =>
|
||||
return Err(self.get(2)?.error(CompileErrorKind::DeprecatedEquals)),
|
||||
Some(Keyword::Export) if self.next_are(&[Identifier, Identifier, ColonEquals]) => {
|
||||
self.presume_keyword(Keyword::Export)?;
|
||||
items.push(Item::Assignment(self.parse_assignment(true)?));
|
||||
},
|
||||
Some(Keyword::Set)
|
||||
if self.next_are(&[Identifier, Identifier, ColonEquals])
|
||||
|| self.next_are(&[Identifier, Identifier, Eol])
|
||||
|| self.next_are(&[Identifier, Identifier, Eof])
|
||||
{
|
||||
items.push(Item::Set(self.parse_set()?));
|
||||
} else {
|
||||
let doc = pop_doc_comment(&mut items, eol_since_last_comment);
|
||||
items.push(Item::Recipe(self.parse_recipe(doc, false)?));
|
||||
},
|
||||
|| self.next_are(&[Identifier, Identifier, Eof]) =>
|
||||
items.push(Item::Set(self.parse_set()?)),
|
||||
_ =>
|
||||
if self.next_are(&[Identifier, Equals]) {
|
||||
return Err(self.get(1)?.error(CompileErrorKind::DeprecatedEquals));
|
||||
|
Loading…
Reference in New Issue
Block a user