Q0 Set up : svn export http://unbox.org/wisp/var/timm/10/310/src/st/3/a : svn add a : svn commit -m "3a ready to go" : For each of the following questions, add lines like this to "run" printf "\n===== 3/a/q1 ========================\n\n" cat myCodeThatAnswersThisQuestion.st execute : where "execute" is the "test" command shown below. Q1 Write : Write a Smallk String method that assumes the receiver is a : filename. : Write out that file, line by line. Predix each line with : its line number. Hints: if will begine like this Create a file String.st Start typing ! String methods ! asFileWithLineNumbers "insert your code here" !! Edut Z.st 'testfilename.dat' asFileWithLineNumbers ! See if it works bash run Test : 'testfilename.dat' asFileWithLineNumbers Hint : 0lib.st, fileLinesDo: Q2 Write : Write Smalltalk code that that reads every line of input into an array. : Then print that array in reverse order. Test : 'testfilename.dat' asFileLines reverse printNumbered ! Hint : Create files String.st and SeqCollect.st. : "asFileLines" is one of your new String method that returns an OrderedCollection of all the lines : reverse is a Smalltalk builit : "printNumbers" is your new SequenceableCollection method that prints the reciever, : with a item number at the front. Q3 Write : Write an Smalltalk program that prints out (one per line) all the : left-hand-side "variables" (i.e. : non-terminals"). : Test that on english.rules Test : |g| g:= Grammar new. g file: 'english.rules'. g lhs. ! Hint : Of all the above code, only "lhs" is new. Q4 Write : Write a Smalltalk program that prints out (one per line) all the : right-hand-side "variables" (i.e. : non-terminals"). : Test that on english.rules Test : |g| g:= Grammar new. g file: 'english.rules'. g rhs. ! Hint : 1) Inside Grammar class : rules associationsDo: [:pair | pair value do: [:rhsSymbol| ...]]. : 2) This code requires "g lhs" since to decide if a rhs symbol needs : printing, you must check that it does not appear on the lhs.