MCPcopy Create free account
hub / github.com/foxcpp/maddy / parseAsMacro

Method parseAsMacro

framework/cfgparser/parse.go:191–206  ·  view source on GitHub ↗
(node *Node)

Source from the content-addressed store, hash-verified

189}
190
191func (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//

Callers 1

readNodeMethod · 0.95

Calls 1

ErrMethod · 0.80

Tested by

no test coverage detected