| 189 | } |
| 190 | |
| 191 | func (ctx *parseContext) parseAsMacro(node *Node) (macroName string, args []string, err error) { |
| 192 | if !strings.HasPrefix(node.Name, "$(") { |
| 193 | return "", nil, nil |
| 194 | } |
| 195 | if !strings.HasSuffix(node.Name, ")") { |
| 196 | return "", nil, ctx.Err("macro name must end with )") |
| 197 | } |
| 198 | macroName = node.Name[2 : len(node.Name)-1] |
| 199 | if len(node.Args) < 2 { |
| 200 | return macroName, nil, ctx.Err("at least 2 arguments are required") |
| 201 | } |
| 202 | if node.Args[0] != "=" { |
| 203 | return macroName, nil, ctx.Err("missing = in macro declaration") |
| 204 | } |
| 205 | return macroName, node.Args[1:], nil |
| 206 | } |
| 207 | |
| 208 | // readNodes reads nodes from the currently parsed block. |
| 209 | // |