Skip to content

Commit

Permalink
Parameterized goals #115
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Jan 20, 2023
1 parent ec9688c commit 13ef22c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ BEGIN {
split("",Lib) # name -> code
split("",UseLibLineNo)# name -> line no.
split("",GoalToLib)# goal name -> lib name
split("",Quotes) # NF -> quote of field ("'"|"$"|"")
Mode = "prelude" # prelude|define|goal|goal_glob|lib
srand()
prepareArgs()
Expand Down Expand Up @@ -302,7 +303,7 @@ function registerDependsOn(goalName, i,dep,x,y) {
x = goalName SUBSEP DependenciesCnt[goalName]
y = x SUBSEP DependencyArgsCnt[x]++
DependencyArgs[y] = $i
DependencyArgsType[y] = "string" # TODO
DependencyArgsType[y] = Quotes[i] ? "string" : "var"
}
} else
registerDependency(goalName, dep)
Expand Down Expand Up @@ -723,6 +724,7 @@ function parseCli(line, res, pos,c,last,is_doll,c1) {
pos++
# consume quoted string
res[last = res[-7]++] = ""
res[last,"quote"] = is_doll ? "$" : "'"
while((c = substr(line,++pos,1)) != "'") { # closing '
if (c=="")
return "unterminated argument"
Expand All @@ -736,7 +738,7 @@ function parseCli(line, res, pos,c,last,is_doll,c1) {
} else {
# consume unquoted argument
res[last = res[-7]++] = c
while((c = substr(line,++pos,1)) != "" && c != " " && c != "\t") { # whitespace denotes end of arg
while((c = substr(line,++pos,1)) != "" && c != " " && c != "\t") { # whitespace denotes the end of arg
if(c=="'")
return "joined arguments"
res[last] = res[last] c
Expand All @@ -751,8 +753,10 @@ function reparseCli( res,i,err) {
addError("Syntax error: " err)
die(Error)
} else
for (i=NF=0; i in res; i++)
for (i=NF=0; i in res; i++) {
$(++NF)=res[i]
Quotes[NF]=res[i,"quote"]
}
}
function quote2(s,force) {
if (index(s,"'")) {
Expand Down

0 comments on commit 13ef22c

Please sign in to comment.