Skip to content

Commit

Permalink
Support interpolation including parameterized goal params #153 rfct
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 3, 2024
1 parent 3698bba commit b0b6554
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function registerDependsOn(goalName, i,dep,x,y) {
if ("@args" == dep) {
if (i != 3)
addError("@args only allowed at position 3")
DependencyArgsNR[goalName,DependenciesCnt[goalName]-1] = NR
DependencyArgsNR[goalName, DependenciesCnt[goalName] - 1] = NR
break
} else
registerDependency(goalName, dep)
Expand Down Expand Up @@ -618,12 +618,11 @@ function instantiateGoals( i,l,goalName) {
#
# args: { F => "file1" }
#
function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInstantiated,argsCnt,gi,gii,argsCode,a) { # -> goalNameInstantiated
function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInstantiated,argsCnt,gi,gii,argsCode,reparsed) { # -> goalNameInstantiated
if (goal in Instantiated) return goal
# indent(IDepth++); print "instantiating " goal " { " renderArgs(args) "} ..."
# indent(IDepth++); print "instantiating " goal " { " renderArgs(args) "} ..."

goalNameInstantiated = instantiateGoalName(goal, args)
Instantiated[goalNameInstantiated]
Instantiated[goalNameInstantiated = instantiateGoalName(goal, args)]

if (goalNameInstantiated != goal) {
if (!(goalNameInstantiated in GoalsByName))
Expand All @@ -649,11 +648,13 @@ function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInst

argsCnt = 0
if (gi in DependencyArgsNR) {
delete a
# already should not fails syntax - we don't check result code
parseCli_2(Lines[DependencyArgsNR[gi]],args,Vars,a)
delete reparsed
# The idea behind deferring this reparsing to instantiation is to be able to reference both @define vars and PG
# params in PG arg string interpolation.
# Already should not fails syntax (checked earlier) - we don't check result code.
parseCli_2(Lines[DependencyArgsNR[gi]], args, Vars, reparsed)

argsCnt = a[-7]-3 # TODO comment
argsCnt = reparsed[-7] - 3 # -7 holds len. Subtracting 3, because args start after `@depends_on pg @args`
}

# we do not report wrong args count for unknown deps
Expand All @@ -663,8 +664,8 @@ function instantiate(goal,args,newArgs, i,j,depArg,depArgType,dep,goalNameInst
# indent(IDepth); print ">dep=" dep ", argsCnt[" gi "]=" argsCnt

for (j = 0; j < argsCnt; j++) {
depArg = a[j+3]
depArgType = "u" == a[j+3,"quote"] ? "var" : "str"
depArg = reparsed[j + 3]
depArgType = "u" == reparsed[j + 3, "quote"] ? "var" : "str"

# indent(IDepth); print ">>@ " depArg " " depArgType

Expand Down

0 comments on commit b0b6554

Please sign in to comment.