#!/usr/bin/gawk -f BEGIN { Comments = "#.*"; _min = 0; _max = 1; NumberP = 1; DiscreteP = 2; } END { print "BEGIN {"; print "\t_min=" _min ";"; print "\t_max=" _max ";"; print "\tNumberP=" NumberP ";"; print "\tDiscreteP=" DiscreteP ";"; saya("\tType", Type,1,0,";"); saya(" \tOk", Ok, 1,0,";"); print "}" ; } { sub(Comments,"") } # kill blanks /^[ \t]*$/ { next } # skip blanks NF < 3 { next } # skip short { This = type(); # what are you? Type[$1]= This } This == NumberP { for(I=3;I<=NF;I++) { # get discrete deails Ok[$1,_min] = $3; Ok[$1,_max] = $5; } } This == DiscreteP { for(I=3;I<=NF;I++) # get num details Ok[$1,$I] = 1; } function type() { #as a side effect, culls any meta symbols in $1 if (sub(/^[ \t]*\%/,"",$1)) return $3 == "any" ? 0 : NumberP; if (sub(/^[ \t]*\_/,"",$1)) return $3 == "any" ? 0 :DiscreteP; if ($3 == "any") return 0; return DiscreteP; } function saya(s,a,q1,q2,eol, i,j,n,tmp,str,sep) { q1= q1 ? "\"" : ""; q2= q2 ? "\"" : ""; for(i in a) { sep=""; str= s"["; n=split(i,tmp,SUBSEP); for(j=1;j<=n;j++) { str=str sep q1 tmp[j] q1; sep=","; } print str "] = " q2 a[i] q2 eol | "sort"; }; close("sort"); }