Next / Previous / Contents / Shipman's homepage

20. class StdHead: The common front part of a standard forms line

An instance of this class represents the initial fields that are common to all standard forms line. Here is the class interface. The status code must be a one-character string; see Section 6.21, “STATUS_RE.

# - - - - -   c l a s s   S t d H e a d

class StdHead(object):
    '''Represents the front part of a standard forms line.

        StdHead ( hier, scan ):
          [ (hier is a Hier instance) and
            (scan is a Scan instance) ->
              if the line in scan starts with a standard forms head ->
                if the rank code is in hier ->
                  scan  :=  scan advanced past the head
                  return a new StdHead instance representing the head
                else ->
                  scan  :=  scan not advanced past end of line
                  raise KeyError
              else ->
                scan  :=  scan advanced not past end of line
                Log()  +:=  error messages
                raise SyntaxError ]
          [ if the head had no rank code -> None
            else -> the rank as a Rank instance in hier ]
          [ the status code as a string that matches STATUS_RE ]