Skip to content

Commit

Permalink
Fix application of attributes to prereqs by using [[prereqs]][attribs…
Browse files Browse the repository at this point in the history
…] syntax
  • Loading branch information
zyedidia committed Apr 25, 2023
1 parent 512d0dd commit 70d3e5b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions rules/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,24 @@ func parseRecipe(p *parser, t token) parserStateFun {
k++
switch t.typ {
case tokenLSquare:
for k < len(p.tokenbuf) && p.tokenbuf[k].typ != tokenRSquare {
p, n := getPrereq(k)
prereqs = append(prereqs, p...)
k = n
// second [
if k < len(p.tokenbuf) && p.tokenbuf[k].typ == tokenLSquare {
k++
for k < len(p.tokenbuf) && p.tokenbuf[k].typ != tokenRSquare {
p, n := getPrereq(k)
prereqs = append(prereqs, p...)
k = n
}
k++
if !(k < len(p.tokenbuf) && p.tokenbuf[k].typ == tokenRSquare) {
if k >= len(p.tokenbuf) {
k = len(p.tokenbuf) - 1
}
p.basicErrorAtToken("did not find second ']' to close '[[' list", p.tokenbuf[k])
return prereqs, k
}
k++
}
k++
case tokenWord:
prereqs = append(prereqs, prereq{name: filepath.Clean(t.val)})
}
Expand All @@ -315,6 +327,9 @@ func parseRecipe(p *parser, t token) parserStateFun {
if t.typ != tokenLSquare {
return prereqs, k
}
if k+1 >= len(p.tokenbuf) || p.tokenbuf[k+1].typ == tokenLSquare {
return prereqs, k
}

attribs := &bytes.Buffer{}
k++
Expand All @@ -339,7 +354,7 @@ func parseRecipe(p *parser, t token) parserStateFun {
for i := range prereqs {
prereqs[i].addAttrs(attrs)
}
return prereqs, k
return prereqs, k + 1
}
var preq []prereq
var k int
Expand Down

0 comments on commit 70d3e5b

Please sign in to comment.