def METHOD_NAME(self, lexer:Lexer, input:InputStream, startIndex:int):
    requiresSeek = False
    stopIndex = input.index
    try:
        for lexerAction in self.lexerActions:
            if isinstance(lexerAction, LexerIndexedCustomAction):
                offset = lexerAction.offset
                input.seek(startIndex + offset)
                lexerAction = lexerAction.action
                requiresSeek = (startIndex + offset) != stopIndex
            elif lexerAction.isPositionDependent:
                input.seek(stopIndex)
                requiresSeek = False
            lexerAction.METHOD_NAME(lexer)
    finally:
        if requiresSeek:
            input.seek(stopIndex)