Chris Pollett>Old Classes>CS170, Fall 1998>Hw4
Due at start of class, Tuesday, Nov. 17, 1998. Read to page 234 in P&Z. Then do the following exercises from P&Z:
p.187-190 14, 15 (left over from last homework) p. 235 2,4. In addition, write the following program which will help you towards your final project. This program takes as input a character line, extracts a string from it and returns true or false. Here is a prototype for this function. BOOL sItemParse(char **line, char **string); If the input **line is not a double quote or an upper case letter it returns FALSE and *string should be NULL. i.e., on input where *line points to the dog jumped. sItemParse returns FALSE, *string would be NULL and line, *line, **line are unchanged. If **line is an uppercase letter then *string should point to the string consisting of a v followed by a copy of the string pointed to by *line up to the first character which is not an (upper/lower case) letter or a number. *line should then be advance to this character and sItemParse should return TRUE. i.e., on input where *line points to The dog jumped. sItemParse returns TRUE. *line is set to point to the space after The and *string is set to point at vThe If **line is double quote then *string should point to the string consisting of an s followed by a string which consists of characters after *line up to the next " not preceded by a blackslash except that \\ is converted to \ and \" is " and single \ followed by any other character are replaced with that other character. If no double quote not preceded by a backslash exists in *line then sItemParse returns FALSE. Otherwise, *line is advanced to the character after this " and sItemParse returns true. i.e., on input where *line points to "The dog said, \"good\\bad\"" things sItemParse returns TRUE, *line is set to point to the space before things and *string points to sThe dog said, "good\bad" Hint: You try to come up with a finite state machine that performs these transformation and then implement it. In addition write a short program which can be used to show your program works. Submit printouts of your code with your homework together with a printout showing your program works.