BEGIN			{ print "file=\"/tmp/bm.output\"\n>$file"
			  ORS=""
			  OFS=""
			}
# lines beginning with "file" change the output file - default "bm.output"
/^file/			{ print "file=$2\n"
			  next
			}
# matches Blackboard querys, ie lines of the form "% n = no_zones" are converted into
# a query of the u_cpt area of the Blackboard for the data associated with "no_zones"
/^%/			{ print "echo \"query	u_cpt	"
			  for (i = 4; i <= NF; i++ )
			  	print "	" $i
			  print "\" >&1; read junk junk"
			  for (i = 4; i <= NF; i++ )
				printf " junk"
			  printf " " $2 " <&0\n"
			  next
			}
# match literal data - ie lines completely enclosed in quotes
/^[ 	]*".*"[	 ]*$/	{ print "echo " $0 " >> $file\n"
			  next
			}
# match "special" for loops, ie lines of the form "   forall i upto $n
/^[ 	]*forall[ 	][^ 	]*[ 	]upto[ 	]/ {
			  forindex=$2
			  print "index_" $2 "=0\n"
			  print "while index_" $2 "="
			  print     "` expr ${index_" $2 "} + 1 ` || true  &&"
			  print     "  [ $index_" $2 " -le " $4 " ] \n"
			  next
			}
/^[ 	]*do[ 	]*$/	{
			  print "do\n"
			  print forindex "=` expr ${index_" forindex "} - 1 `\n"
			  next
			}
# matches everything else - eg variable assignment, if-for-switch cmds, etc
/.*/			{ print $0 "\n"
			  next
			}
