CSC 216/s08/seek reconciliation: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
===Formatting Resources=== | ===Formatting Resources=== | ||
[http://meta.wikimedia.org/wiki/Help:Wikitext_examples Formatting Help Guide from MetaWiki] | [http://meta.wikimedia.org/wiki/Help:Wikitext_examples Formatting Help Guide from MetaWiki] | ||
==Finite State Machines== | |||
<br> | |||
<br> | |||
==Floating Point FSM Exercise== | ==Floating Point FSM Exercise== |
Revision as of 01:57, 15 April 2008
Formatting Resources
Formatting Help Guide from MetaWiki
Finite State Machines
Floating Point FSM Exercise
The problem
The exercise will illustrate the "State" programming paradigm through the floating point parser finite state machine discussed in class.
Participants and props
4 students will participate. 3 for each "State" (Start, Decimal, Integer) and one to represent the "parser." The parser will have a piece of paper with the numbers to be parsed on it, with space in between the numbers to write the output. Each person representing a state will hold up a piece of paper. On the front will be the name of that person's state. On the back will be the actions to perform based on the input given by the parser. Here are the instructions:
Start
Plus: sign is positive; GOTO Integer
Minus: sign is negative; GOTO Integer
Decimal: sign is positive; write decimal; GOTO Decimal
Digit: sign is positive; add digit; GOTO Integer
Other: Error
Decimal
Plus: Error
Minus: Error
Decimal: Error
Digit: add digit; GOTO Decimal
Other: Error
Integer
Plus: Error
Minus: Error
Decimal: add digit; write decimal; GOTO Decimal
Digit: add digit; GOTO Integer
Other: Error
NOTE: adding a digit means writing it in the next decimal place
The script
The "parser" will start at the "Start" state. The "parser" will tell the state what the first character of the input is, being either a "plus", "minus", "decimal", "digit", or "other". The state will tell the "parser" to perform the action stated on the back of their sheet. This continues until either the "parser" reaches the end of the number or if an error occurs. Repeat for different cases.