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