Q0 Set up : Get your stuff working under subversion : Go to 310/cs310gpXX/1 : svn export http://unbox.org/wisp/var/timm/10/310/src/gawk/1/b : svn add b : svn commit -m "b ready to go" : For each of the following questions, add lines like this to "run" printf "\n===== 1/b/q1 ========================\n\n" cat myCodeThatAnswersThisQuestion.awk execute : where "execute" is the "test" command shown below. Q1 Write : Write an awk program that reads every line, and outputs that line, with : its line number. : Use that file to write out this file. Test : gawk -f linenum.awk linenum.awk Hint : The curent line number is stored in FNR Q2 Write : Write an awk loop that reads every line of input into an array. : Then print that array in reverse order. Test : gawk -f reverse.awk linenum.awk Hint : The current line number is the variable FNR. : The last thing Awk does is to run the code in 'END { codeToRunLast }' : Line 96 of stork.awk shows a for loop Q3 Write : Write an awk program that prints out (one per line) all the : left-hand-side "variables" (i.e. : non-terminals"). : Test that on scifi.rules Test : gawk -f lhs.awk scifi.rules Hint : $1 Q4 Write : Write an awk program that prints out (one per line) all the : right-hand-side "variables" (i.e. : non-terminals"). : Test that on scifi.rules Test : gawk -f rhs.awk scifi.rules Hint : for(i=1;i<=NF;i++) print "the " i "-th field is " $i Q5 Write : Write an awk program that prints out (one per line) all the : right-hand-side "variables" not found on the left hand side. : Test that on scifi.rules Test : gawk -f badright.awk scifi.rules Hint : combine Q3,Q4 code Q5 Write : Write an awk program that prints out (one per line) all the : left "variables" that never appear on the right hand side. Test : gawk -f badleft.awk scifi.rules Hint : combine Q3,Q4 code