(exprID int64, function string, target ast.Expr, args ...ast.Expr)
| 355 | } |
| 356 | |
| 357 | func (p *prattParserWorker) expandMacro(exprID int64, function string, target ast.Expr, args ...ast.Expr) (ast.Expr, bool) { |
| 358 | if len(p.macros) == 0 { |
| 359 | return nil, false |
| 360 | } |
| 361 | macro, found := p.macros[makeMacroKey(function, len(args), target != nil)] |
| 362 | if !found { |
| 363 | macro, found = p.macros[makeVarArgMacroKey(function, target != nil)] |
| 364 | if !found { |
| 365 | return nil, false |
| 366 | } |
| 367 | } |
| 368 | if int(p.helper.expressionCount()) > p.maxExpressionNodeCount { |
| 369 | loc := p.helper.getLocation(exprID) |
| 370 | p.helper.deleteID(exprID) |
| 371 | return p.reportError(loc, "expression count exceeds limit of %d while expanding macro '%s'", p.maxExpressionNodeCount, function), true |
| 372 | } |
| 373 | eh := exprHelperPool.Get().(*exprHelper) |
| 374 | eh.parserHelper = p.helper |
| 375 | eh.id = exprID |
| 376 | expr, err := macro.Expander()(eh, target, args) |
| 377 | exprHelperPool.Put(eh) |
| 378 | if int(p.helper.expressionCount()) > p.maxExpressionNodeCount { |
| 379 | loc := p.helper.getLocation(exprID) |
| 380 | p.helper.deleteID(exprID) |
| 381 | return p.reportError(loc, "expression count exceeds limit of %d while expanding macro '%s'", p.maxExpressionNodeCount, function), true |
| 382 | } |
| 383 | if err != nil { |
| 384 | loc := err.Location |
| 385 | if loc == nil { |
| 386 | loc = p.helper.getLocation(exprID) |
| 387 | } |
| 388 | p.helper.deleteID(exprID) |
| 389 | return p.reportError(loc, "%s", err.Message), true |
| 390 | } |
| 391 | if expr == nil { |
| 392 | return nil, false |
| 393 | } |
| 394 | if p.populateMacroCalls { |
| 395 | p.helper.addMacroCall(expr.ID(), function, target, args...) |
| 396 | } |
| 397 | p.helper.deleteID(exprID) |
| 398 | return expr, true |
| 399 | } |
| 400 | |
| 401 | func (p *prattParserWorker) normalizeIdent(tok token, allowQuoted bool, isQuoted *bool) string { |
| 402 | if isQuoted != nil { |
no test coverage detected