CSC 216/s08/seek reconciliation

From Expertiza_Wiki
Revision as of 04:07, 21 April 2008 by Ajbertol (talk | contribs) (→‎Finite State Machines)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Formatting Resources

Formatting Help Guide from MetaWiki

Finite State Machines





Link to powerpoint : http://www4.ncsu.edu/~ajbertol/FiniteStateMachines.pptx



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.