function readModel(filename, model, lookingfor, sections) { #Note: The order of the sections in the model file must match this string split(":aliases :slopes :scalefactors :effortmultipliers :defectremoval", sections, " ") lookingfor = 0 while ((getline < "grammars/model.txt") > 0) { if ($1 ~ /^[ /t]*#/) { continue } #skip comments if ($0 ~ /^[ /t]*$/) { continue } #skip blank lines if ($1 == sections[lookingfor + 1]) { lookingfor++ #moving on to next section continue } if (sections[lookingfor] == ":aliases") { storeAliases(model, $0); continue } if (sections[lookingfor] == ":slopes") { storeSlopes(model, $0); continue } if (sections[lookingfor] == ":scalefactors") { storeCoCo(model, "sf", $0); continue } if (sections[lookingfor] == ":effortmultipliers") { storeCoCo(model, "em", $0); continue } if (sections[lookingfor] == ":defectremoval") { storeDefectRemoval(model, $0); continue } } close("grammars/model.txt") } function storeAliases(arr, sourceStr, i,records,value) { records[0] = split(sourceStr, records, " ") value = records[1] for (i = 3; i <= records[0]; i++) arr[getAlias(records[i])] = value } function storeSlopes(arr, sourceStr, i, records, key, max, min) { split(sourceStr, records, " ") key = records[1] max = records[2] min = records[3] arr[getSlopeMax(key)] = max arr[getSlopeMin(key)] = min } #name range(min-max) effslp reqslp designslp codeslope function storeCoCo(arr, type, sourceStr, i, records, range, key) { split(sourceStr, records, " ") split(records[2], range, "-") key = records[1] storeKey(arr, type, key) arr[getRangeMin(key)] = range[1] arr[getRangeMax(key)] = range[2] arr[getEffortSlope(key)] = records[3] arr[getReqSlope(key)] = records[4] arr[getDesignSlope(key)] = records[5] arr[getCodeSlope(key)] = records[6] } function storeKey(arr, type, key) { if (type == "em") { if(arr[getEMKeys()]) arr[getEMKeys()] = arr[getEMKeys()]" "key else arr[getEMKeys()] = key #avoid leading space if keys string is empty } else if (type == "sf") { if(arr[getSFKeys()]) arr[getSFKeys()] = arr[getSFKeys()]" "key else arr[getSFKeys()] = key #avoid leading space if keys string is empty } else if (type == "dr") { if(arr[getDRKeys()]) arr[getDRKeys()] = arr[getDRKeys()]" "key else arr[getDRKeys()] = key #avoid leading space if keys string is empty } #no matter the type, keep a copy in all keys found as well if(arr[getKeys()]) arr[getKeys()] = arr[getKeys()]" "key else arr[getKeys()] = key #avoid leading space if keys string is empty } function storeDefectRemoval(arr, sourceStr, i, records, range, key) { split(sourceStr, records, " ") split(records[2], range, "-") key = records[1] arr[getRangeMin(key)] = range[1] arr[getRangeMax(key)] = range[2] arr[getReqSlope(key)] = records[4] arr[getDesignSlope(key)] = records[5] arr[getCodeSlope(key)] = records[5] storeKey(arr, "dr", key) }