<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse(self, nodes):
 """Given a stream of node data, try to parse the nodes according to the machine's graph."""

    self.last_node_type = self.initial_node_type
    for node_number, node in enumerate(nodes):
      try:
        self.step(node)
      except Exception as ex:
        raise Exception("An error occurred on node {}".format(node_number)) from ex