Skip to content

Commit

Permalink
Propose a method to have parameterized goals #12
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Mar 22, 2021
1 parent 574d49c commit 824cd08
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions makesure.awk
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ BEGIN {
split("",Args) # parsed CLI args
split("",ArgGoals) # invoked goals
split("",Options)
split("",GoalNames)
split("",GoalNames) # list
split("",GoalsByName) # name -> ""
split("",Code) # name -> body
split("",DefineOverrides) # k -> v
DefinesFile=""
split("",Dependencies) # name,i -> dep goal
split("",DependenciesCnt) # name -> dep cnd
split("",Doc) # name,i -> doc str
split("",DocCnt) # name -> doc lines cnt
split("",Code) # name -> body
split("",ReachedIf) # name -> condition line
split("",ScriptNames) # list
split("",ScriptsByName) # name -> ""
split("",Script) # script name -> body
Mode = "prelude" # prelude/goal/script
srand()
Expand Down Expand Up @@ -150,9 +152,10 @@ function adjustOptions() {
delete Options["timing"]
}

function handlePreludeEnd() { if (isPrelude()) adjustOptions() }

function handleGoal( goal_name) {
if (isPrelude()) # 1st goal
adjustOptions()
handlePreludeEnd()

Mode = "goal"

Expand All @@ -167,6 +170,22 @@ function handleGoal( goal_name) {
GoalsByName[goal_name]
}

function handleScript( script_name) {
handlePreludeEnd()

Mode = "script"

script_name = trim($2)
if (length(script_name) == 0) {
die("Script must have a name")
}
if (script_name in ScriptsByName) {
die("Script " script_name " is already defined")
}
arrPush(ScriptNames, script_name)
ScriptsByName[script_name]
}

function handleDoc( goal_name) {
checkGoalOnly()

Expand Down Expand Up @@ -199,10 +218,6 @@ function handleReachedIf( goal_name) {
ReachedIf[goal_name] = trim($0)
}

function handleScript() {
Script[$1]
}

function handleCall() {
}

Expand Down

0 comments on commit 824cd08

Please sign in to comment.