Next / Previous / Contents / Shipman's homepage

20.3. StdHead.__scanStatus()

nomcompile3
# - - -   S t d H e a d . _ _ s c a n S t a t u s

    def __scanStatus ( self, scan ):
        '''Process the status code field.

          [ scan is a Scan instance ->
              if scan starts with a valid status field ->
                scan  :=  scan advanced past that field
                self.status  :=  that field
              else ->
                scan  :=  scan advanced not past end of line
                Log()  +:=  error message(s)
                raise SyntaxError ]
        '''

The regular expression used to match valid status codes is defined in Section 6.21, “STATUS_RE.

nomcompile3
        #-- 1 --
        # [ if the line in scan starts with a string matching
        #   STATUS_RE ->
        #     scan  :=  scan advanced past that string
        #     self.status  :=  matching string
        #   else ->
        #     scan  :=  scan advanced no further than end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        m = scan.tabReMatch ( STATUS_RE )
        if m is None:
            scan.syntax ( "Expecting a status code." )
        else:
            self.status = m.group()