title: Parsing file using finite state machine
body: <p>I am implementing my own fsm to parse a file. I am new to fsm pattern so trying to learn about it. </p>
  
  <p>My fsm class takes a stream of the file that is being parsed along with the current state and a collection of all accepting states. </p>
  
  <p>Now I am confused about couple of things. </p>
  
  <ol>
  <li><p>How does the fsm move through states and keep track of what has been parsed so far?</p></li>
  <li><p>What information should the state object store? Right now they have a pattern that they match on the line and see if fsm can move to this state or not. </p></li>
  </ol>
  
  <p>Example:</p>
  
  <p>File to parse:</p>
  
  <pre><code>Person:  bob smith
          Age: 33
          Location: new York
  End person
  Person:  Jane smith
          Age: 66
          Location: Chicago
  End person
  </code></pre>
  
  <p>So I have a state for person start, age, location and end person. Each state object has a patter. (regex) to check if the given line is accepted by them or not. </p>
  
  <p>But I am stuck on how would I construct a Person object when parsing this file using fsm??</p>