Let's take the parser of a turtle graphics implementation as an example.  The program will receive commands such as REPEAT 4\[FD 100, RT 90\] and will output pictures , in this case a square. One of the modules required will be a parser. The parser will have to * receive a string * split it according to white space * tokenize it ie recognise logo commands and arguments * chunk the tokens into commands (eg fd 100 rt 90) * check that the string is properly formed (so it doesn't say fd 100 90 30 rt for example. All correct tokens but they don't make sense in that order) * form set of commands to pass to the renderer (the thing that will draw the shapes) Now you break down each of those steps so to tokenize for example * Walk through the individual parts of the command (fd, 100, rt, 90) * Check if they are valid commands or arguments * output an error if not * form a string of tokens representing the string So for the tokenize module we'll need to do the following: | | | | --- | --- | | Sketches | Not appropriate here | | Data representation | FD: FD, Forward<br>RT: RT, Right<br>number: number<br>REPEAT: RE<br>\[ : \[\[ | | Sample Data | FD 100<br>RT 90<br>FD 100, RT  90<br>REPEAT 4 \[FD 100\]<br>REPEAT 4\[FD 100, RT 90\] | | Description of algorithms | Below is a basic outline.  Each step needs to be broken down into substeps<br><br>1. receive a string<br>2. split it according to white space<br>3. tokenize it ie recognise logo commands and arguments<br> 1. loop across list array<br> 2. for each item in the array look up valid tokens<br> 3. <br>4. chunk the tokens into commands (eg fd 100 rt 90)<br>5. check that the string is properly formed (so it doesn't say fd 100 90 30 rt for example. All correct tokens but they don't make sense in that order)<br>6. form set of commands to pass to the renderer (the thing that will draw the shapes) | | Code | * Include Pseudocode and/or copy and paste appropriate code from implementation here<br>* Which one? Whichever explains the best.  For a complex algorithm, pseudocode is probably best |