Next / Previous / Contents / Shipman's homepage

39. Scan.tabMatch(): Advance if there is a match

logscan.py
# - - -   S c a n . t a b M a t c h

    def tabMatch(self, s):
        '''If s matches at the current position, advance past it.
        '''
        #-- 1 --
        # [ if the current position starts with s ->
        #     endPos  :=  the position just after the match
        #   else ->
        #     endPos  :=  none ]
        endPos = self.match(s)

        #-- 2 --
        # [ if endPos is None ->
        #     return None
        #   else ->
        #     self  :=  self advanced to endPos
        #     return current line between self.pos and endPos ]
        if endPos is None:
            return None
        else:
            return self.tab(endPos)